kubernetes-sigs / cluster-api-provider-openstack

Cluster API implementation for OpenStack
https://cluster-api-openstack.sigs.k8s.io/
Apache License 2.0
275 stars 253 forks source link

Manager panics when executed without a valid kube context #2054

Closed mdbooth closed 2 months ago

mdbooth commented 2 months ago

/kind bug

podman run --rm -ti gcr.io/k8s-staging-capi-openstack/capi-openstack-controller:v0.10.1 -- --version    
E0503 16:03:01.692120       1 config.go:133] "unable to load in-cluster config" err="unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined" logger="controller-runtime.client.config"
E0503 16:03:01.693959       1 main.go:235] "unable to get kubeconfig" err="invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable" logger="setup"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x1d0 pc=0x1ba6cc8]

goroutine 1 [running]:
main.main()
        /workspace/main.go:237 +0x3c8

Looks like we're missing an exit here: https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/2214514acdc66dbb40677a130dd3b7a7c058149e/main.go#L231-L235

Note that it didn't crash in v0.9.0, but I suspect that was due to luck. I'm guessing this broke when we bumped controller-runtime.