kudobuilder / kudo

Kubernetes Universal Declarative Operator (KUDO)
https://kudo.dev
Apache License 2.0
1.17k stars 103 forks source link

Nil Map Panic #1742

Closed kensipe closed 3 years ago

kensipe commented 3 years ago

What happened:

Installation of the latest Cassandra cassandra-3.11.7-1.0.2 which isn't released yet... causes a panic at the controller during installation. It isn't clear if this operator is valid (it passes current validation during bundling) but the panic should NEVER happen at the controller.

What you expected to happen:

Installation C* or an Error message indicating the issue.

How to reproduce it (as minimally and precisely as possible):

k kudo install cassandra for 1.0.2 operator. For me that was k kudo install ./operator on the master of the current cassandra GH repo

Anything else we need to know?:

Panic Trace

2020/11/13 19:28:34 OperatorVersionController: Received Reconcile request for an operatorVersion named: cassandra-3.11.7-1.0.2
2020/11/13 19:28:34 http: panic serving 192.168.188.64:40692: assignment to entry in nil map
goroutine 13883 [running]:
net/http.(*conn).serve.func1(0xc000df0140)
    /usr/local/Cellar/go/1.15.3/libexec/src/net/http/server.go:1801 +0x147
panic(0x174fdc0, 0x1ae55c0)
    /usr/local/Cellar/go/1.15.3/libexec/src/runtime/panic.go:975 +0x47a
github.com/kudobuilder/kudo/pkg/webhook.setImmutableParameterDefaults(0xc000145680, 0xc000e965a0)
    /Users/jan/Documents/konvoy/kudo/pkg/webhook/instance_admission.go:468 +0x178
github.com/kudobuilder/kudo/pkg/webhook.handleCreate(0xc000768d80, 0xc001792ed0, 0x24, 0xc001731e58, 0x8, 0xc001731e70, 0x7, 0xc001731e78, 0x8, 0xc001731e88, ...)
    /Users/jan/Documents/konvoy/kudo/pkg/webhook/instance_admission.go:93 +0x4e7
github.com/kudobuilder/kudo/pkg/webhook.(*InstanceAdmission).Handle(0xc000768d80, 0x1b3b680, 0xc002c7cc80, 0xc001792ed0, 0x24, 0xc001731e58, 0x8, 0xc001731e70, 0x7, 0xc001731e78, ...)
    /Users/jan/Documents/konvoy/kudo/pkg/webhook/instance_admission.go:50 +0x1f8
sigs.k8s.io/controller-runtime/pkg/webhook/admission.(*Webhook).Handle(0xc000541140, 0x1b3b680, 0xc002c7cc80, 0xc001792ed0, 0x24, 0xc001731e58, 0x8, 0xc001731e70, 0x7, 0xc001731e78, ...)
    /Users/jan/Documents/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.3/pkg/webhook/admission/webhook.go:135 +0xd5
sigs.k8s.io/controller-runtime/pkg/webhook/admission.(*Webhook).ServeHTTP(0xc000541140, 0x7f89a2f3f5f8, 0xc002ae4a00, 0xc0006ac400)
    /Users/jan/Documents/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.6.3/pkg/webhook/admission/http.go:87 +0xbd8
github.com/prometheus/client_golang/prometheus/promhttp.InstrumentHandlerInFlight.func1(0x7f89a2f3f5f8, 0xc002ae4a00, 0xc0006ac400)
    /Users/jan/Documents/go/pkg/mod/github.com/prometheus/client_golang@v1.7.1/prometheus/promhttp/instrument_server.go:40 +0xab
net/http.HandlerFunc.ServeHTTP(0xc0005413b0, 0x7f89a2f3f5f8, 0xc002ae4a00, 0xc0006ac400)
    /usr/local/Cellar/go/1.15.3/libexec/src/net/http/server.go:2042 +0x44
github.com/prometheus/client_golang/prometheus/promhttp.InstrumentHandlerCounter.func1(0x1b37440, 0xc000bf60e0, 0xc0006ac400)
    /Users/jan/Documents/go/pkg/mod/github.com/prometheus/client_golang@v1.7.1/prometheus/promhttp/instrument_server.go:100 +0xda
net/http.HandlerFunc.ServeHTTP(0xc000541500, 0x1b37440, 0xc000bf60e0, 0xc0006ac400)
    /usr/local/Cellar/go/1.15.3/libexec/src/net/http/server.go:2042 +0x44
github.com/prometheus/client_golang/prometheus/promhttp.InstrumentHandlerDuration.func2(0x1b37440, 0xc000bf60e0, 0xc0006ac400)
    /Users/jan/Documents/go/pkg/mod/github.com/prometheus/client_golang@v1.7.1/prometheus/promhttp/instrument_server.go:76 +0xb2
net/http.HandlerFunc.ServeHTTP(0xc0005415f0, 0x1b37440, 0xc000bf60e0, 0xc0006ac400)
    /usr/local/Cellar/go/1.15.3/libexec/src/net/http/server.go:2042 +0x44
net/http.(*ServeMux).ServeHTTP(0xc000305ec0, 0x1b37440, 0xc000bf60e0, 0xc0006ac400)
    /usr/local/Cellar/go/1.15.3/libexec/src/net/http/server.go:2417 +0x1ad
net/http.serverHandler.ServeHTTP(0xc0006b40e0, 0x1b37440, 0xc000bf60e0, 0xc0006ac400)
    /usr/local/Cellar/go/1.15.3/libexec/src/net/http/server.go:2843 +0xa3
net/http.(*conn).serve(0xc000df0140, 0x1b3b680, 0xc002c7cb40)
    /usr/local/Cellar/go/1.15.3/libexec/src/net/http/server.go:1925 +0x8ad
created by net/http.(*Server).Serve
    /usr/local/Cellar/go/1.15.3/libexec/src/net/http/server.go:2969 +0x36c

Environment:

kensipe commented 3 years ago

https://github.com/kudobuilder/kudo/blob/main/pkg/webhook/instance_admission.go#L465-L467

there is more than 1 reason accessing the map is !ok...

            if _, ok := instance.Spec.Parameters[p.Name]; !ok {
                instance.Spec.Parameters[p.Name] = *p.Default
            }

Looking into the right solution