kubeslice / worker-operator

Kubeslice Worker Operator Opensource Repository: The KubeSlice Worker Operator is a Kubernetes operator that manages the lifecycle of KubeSlice worker clusters.
Apache License 2.0
60 stars 19 forks source link

Webhook internal server error in case deployment annotations are nil #78

Closed rahulsawra98 closed 2 years ago

rahulsawra98 commented 2 years ago

Mutating webhook refers deployment annotations without checking if it is nil (https://github.com/kubeslice/worker-operator/blob/master/pkg/webhook/deploy/webhook.go#L88) this causes webhook to fail and the pod in not admitted in case annotations are nil

{"level":"info","ts":"2022-08-16T12:27:38.152221912Z","msg":"mutating deploy","pod metadata":{"creationTimestamp":null,"labels":{"app":"iperf-sleep"}}}
2022/08/16 12:27:38 http: panic serving 172.30.199.1:39392: assignment to entry in nil map
goroutine 3055 [running]:
net/http.(*conn).serve.func1()
    /usr/local/go/src/net/http/server.go:1802 +0xb9
panic({0x1736e20, 0x1b5fd90})
    /usr/local/go/src/runtime/panic.go:1047 +0x266
github.com/kubeslice/worker-operator/pkg/webhook/deploy.Mutate(...)
    /workspace/pkg/webhook/deploy/webhook.go:88
github.com/kubeslice/worker-operator/pkg/webhook/deploy.(*WebhookServer).Handle(_, {_, _}, {{{0xc000f2ca20, 0x24}, {{0xc00199ea90, 0x4}, {0xc00199ea94, 0x2}, {0xc00199ea96, ...}}, ...}})
    /workspace/pkg/webhook/deploy/webhook.go:70 +0x34e

Possible solution: Check if the annotations are nil before referencing annotations

Akshit42-hue commented 2 years ago

Hey @rahulsawra98, Should I work on it

// @YachikaRalhan

rahulsawra98 commented 2 years ago

hey @Akshit42-hue this is already resolved, forget to close it