Bug 1917759

Summary: Console operator panics after setting plugin that does not exists to the console-operator config
Product: OpenShift Container Platform Reporter: Jakub Hadvig <jhadvig>
Component: Management ConsoleAssignee: Jakub Hadvig <jhadvig>
Status: CLOSED ERRATA QA Contact: Yadan Pei <yapei>
Severity: medium Docs Contact:
Priority: high    
Version: 4.7CC: aos-bugs, jokerman, spadgett, yapei
Target Milestone: ---   
Target Release: 4.7.0   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-02-24 15:54:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Jakub Hadvig 2021-01-19 11:00:21 UTC
Description of problem:
Console operator panics after setting console plugin that does not exists to the console-operator config.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Go to `/k8s/cluster/operator.openshift.io~v1~Console/cluster/yaml` and add to the `spec.plugins` list `missing-plugin` entry, eg.

  logLevel: Normal
  managementState: Managed
  operatorLogLevel: Normal
    - missing-plugin
2. Go to console-operator pod's log

Actual results:
Panic in to logs:
E0119 10:54:21.624187       1 sync_v400.go:513] failed to set service endpoint for "missing-plugin" plugin: consoleplugin.console.openshift.io "missing-plugin" not found
E0119 10:54:21.624790       1 runtime.go:78] Observed a panic: "invalid memory address or nil pointer dereference" (runtime error: invalid memory address or nil pointer dereference)
goroutine 697 [running]:
k8s.io/apimachinery/pkg/util/runtime.logPanic(0x20a9cc0, 0x36cd830)
	/go/src/github.com/openshift/console-operator/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:74 +0x95
k8s.io/apimachinery/pkg/util/runtime.HandleCrash(0x0, 0x0, 0x0)
	/go/src/github.com/openshift/console-operator/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:48 +0x89
panic(0x20a9cc0, 0x36cd830)
	/usr/lib/golang/src/runtime/panic.go:969 +0x1b9
github.com/openshift/console-operator/pkg/console/operator.getServiceHostname(0x0, 0xc000000002, 0x0)
	/go/src/github.com/openshift/console-operator/pkg/console/operator/sync_v400.go:523 +0x49
github.com/openshift/console-operator/pkg/console/operator.(*consoleOperator).GetPluginsEndpointMap(0xc00017ab40, 0xc0019330d0, 0x1, 0x1, 0x7)

Expected results:
Panic should not occur. If the ConsolePlugins is missing on the cluster, it should be logged in the console-operator logs, and that plugin should not be added to the map of enabled console plugins in the `console-config` ConfigMap in the openshift-console namespace.

Additional info:

Comment 2 Yadan Pei 2021-01-22 06:24:06 UTC
1. patch console.operator/cluster with non-existing plugin name
$ oc get console.operator cluster -o json | jq '.spec.plugins'

2. Check console-operator pod log
$ oc logs -f console-operator-6688cd6b9f-jd5bp -n openshift-console-operator
 stream error: stream ID 375; INTERNAL_ERROR") has prevented the request from succeeding
E0122 06:19:31.268670       1 sync_v400.go:513] failed to get "missing-plugin" plugin: consoleplugin.console.openshift.io "missing-plugin" not found
E0122 06:19:33.654813       1 sync_v400.go:513] failed to get "missing-plugin" plugin: consoleplugin.console.openshift.io "missing-plugin" not found

Verified on 4.7.0-0.nightly-2021-01-21-215614

Comment 5 errata-xmlrpc 2021-02-24 15:54:35 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: OpenShift Container Platform 4.7.0 security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.