Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug(shutdown): Fix panic when webhooks are disabled
When webooks are disabled, shutdown procedure produces the following panic error: ``` 2024-08-13T12:45:04.971685297Z INFO shutdown utils/shutdown.go:22 Done clearing finalizers on exit 2024-08-13T12:45:04.971713179Z INFO shutdown utils/shutdown.go:23 Seting webhook failure policies to Ignore on exit 2024-08-13T12:45:04.978386488Z ERROR shutdown utils/shutdown.go:64 Error getting webhook {"error": "validatingwebhookconfigurations.admissionregistration.k8s.io \"sriov-operator-webhook-config\" not found"} panic: runtime error: index out of range [0] with length 0 goroutine 1 [running]: github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils.updateValidatingWebhook(0x37d7788?) /go/src/github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils/shutdown.go:75 +0x198 github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils.updateWebhooks() /go/src/github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils/shutdown.go:64 +0xa5 github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils.Shutdown() /go/src/github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils/shutdown.go:23 +0x14 main.main() /go/src/github.com/k8snetworkplumbingwg/sriov-network-operator/main.go:296 +0x1e6a ``` Fix the panic error and add an end2end test case to cover it. Signed-off-by: Andrea Panattoni <[email protected]>
- Loading branch information