keepalived-operator icon indicating copy to clipboard operation
keepalived-operator copied to clipboard

Controller panics if service annotation is not of the form namespace/name

Open kincl opened this issue 3 years ago • 1 comments

A service annotation of the form:

keepalived-operator.redhat-cop.io/keepalivedgroup: group1

Panics the controller as it tries to log the error at https://github.com/redhat-cop/keepalived-operator/blob/master/controllers/keepalivedgroup_controller.go#L406

E0310 17:53:27.189342       1 runtime.go:78] Observed a panic: "invalid memory address or nil pointer dereference" (runtime error: invalid memory address or nil pointer dereference)
goroutine 817 [running]:
k8s.io/apimachinery/pkg/util/runtime.logPanic(0x16ed4a0, 0x247e2e0)
	/go/pkg/mod/k8s.io/[email protected]/pkg/util/runtime/runtime.go:74 +0x95
k8s.io/apimachinery/pkg/util/runtime.HandleCrash(0x0, 0x0, 0x0)
	/go/pkg/mod/k8s.io/[email protected]/pkg/util/runtime/runtime.go:48 +0x89
panic(0x16ed4a0, 0x247e2e0)
	/usr/local/go/src/runtime/panic.go:969 +0x1b9
github.com/redhat-cop/keepalived-operator/controllers.(*enqueueRequestForReferredKeepAlivedGroup).Create(0xc00000c880, 0x1add8e0, 0xc00153b5c0, 0x1accce0, 0xc000be8500)
	/workspace/controllers/keepalivedgroup_controller.go:406 +0x177
sigs.k8s.io/controller-runtime/pkg/source/internal.EventHandler.OnAdd(0x1ab83c0, 0xc00000c880, 0x1accce0, 0xc000be8500, 0xc00070c730, 0x1, 0x1, 0x188fee0, 0xc00153b5c0)
	/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/source/internal/eventsource.go:63 +0x132
k8s.io/client-go/tools/cache.(*processorListener).run.func1()
	/go/pkg/mod/k8s.io/[email protected]/tools/cache/shared_informer.go:777 +0xc2
k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1(0xc00072ff60)
	/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:155 +0x5f
k8s.io/apimachinery/pkg/util/wait.BackoffUntil(0xc000734f60, 0x1a7f1e0, 0xc000a3db00, 0x16ba801, 0xc0006586c0)
	/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:156 +0xad
k8s.io/apimachinery/pkg/util/wait.JitterUntil(0xc00072ff60, 0x3b9aca00, 0x0, 0x1, 0xc0006586c0)
	/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:133 +0x98
k8s.io/apimachinery/pkg/util/wait.Until(...)
	/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:90
k8s.io/client-go/tools/cache.(*processorListener).run(0xc000ca6180)
	/go/pkg/mod/k8s.io/[email protected]/tools/cache/shared_informer.go:771 +0x95
k8s.io/apimachinery/pkg/util/wait.(*Group).Start.func1(0xc0006387d0, 0xc000272410)
	/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:73 +0x51
created by k8s.io/apimachinery/pkg/util/wait.(*Group).Start
	/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:71 +0x65
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x15afdb7]

goroutine 817 [running]:
k8s.io/apimachinery/pkg/util/runtime.HandleCrash(0x0, 0x0, 0x0)
	/go/pkg/mod/k8s.io/[email protected]/pkg/util/runtime/runtime.go:55 +0x10c
panic(0x16ed4a0, 0x247e2e0)
	/usr/local/go/src/runtime/panic.go:969 +0x1b9
github.com/redhat-cop/keepalived-operator/controllers.(*enqueueRequestForReferredKeepAlivedGroup).Create(0xc00000c880, 0x1add8e0, 0xc00153b5c0, 0x1accce0, 0xc000be8500)
	/workspace/controllers/keepalivedgroup_controller.go:406 +0x177
sigs.k8s.io/controller-runtime/pkg/source/internal.EventHandler.OnAdd(0x1ab83c0, 0xc00000c880, 0x1accce0, 0xc000be8500, 0xc00070c730, 0x1, 0x1, 0x188fee0, 0xc00153b5c0)
	/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/source/internal/eventsource.go:63 +0x132
k8s.io/client-go/tools/cache.(*processorListener).run.func1()
	/go/pkg/mod/k8s.io/[email protected]/tools/cache/shared_informer.go:777 +0xc2
k8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1(0xc00072ff60)
	/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:155 +0x5f
k8s.io/apimachinery/pkg/util/wait.BackoffUntil(0xc0001aff60, 0x1a7f1e0, 0xc000a3db00, 0x16ba801, 0xc0006586c0)
	/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:156 +0xad
k8s.io/apimachinery/pkg/util/wait.JitterUntil(0xc00072ff60, 0x3b9aca00, 0x0, 0x1, 0xc0006586c0)
	/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:133 +0x98
k8s.io/apimachinery/pkg/util/wait.Until(...)
	/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:90
k8s.io/client-go/tools/cache.(*processorListener).run(0xc000ca6180)
	/go/pkg/mod/k8s.io/[email protected]/tools/cache/shared_informer.go:771 +0x95
k8s.io/apimachinery/pkg/util/wait.(*Group).Start.func1(0xc0006387d0, 0xc000272410)
	/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:73 +0x51
created by k8s.io/apimachinery/pkg/util/wait.(*Group).Start
	/go/pkg/mod/k8s.io/[email protected]/pkg/util/wait/wait.go:71 +0x65

kincl avatar Mar 10 '21 17:03 kincl

thanks for letting me know. the error handling should definitely be more graceful.

raffaelespazzoli avatar Mar 10 '21 20:03 raffaelespazzoli