What happened:
Every time the Identity Secret to authenticate against Harvester has a current-context value doesn't exist in the name keys of the cluster section, the CAPHV controller will fail with nil pointer error.
What did you expect to happen:
I expected that the Controller would continue to reconcile normally without CrashLooping.
How to reproduce it:
Put in the cluster manifests, an identity secret that has different names for current-context and cluster.name and apply manifest to management cluster.
What happened: Every time the Identity Secret to authenticate against Harvester has a
current-context
value doesn't exist in thename
keys of thecluster
section, the CAPHV controller will fail withnil
pointer error.What did you expect to happen: I expected that the Controller would continue to reconcile normally without CrashLooping.
How to reproduce it: Put in the cluster manifests, an identity secret that has different names for
current-context
andcluster.name
and apply manifest to management cluster.Anything else you would like to add: Problem is happening at this line in the code: https://github.com/rancher-sandbox/cluster-api-provider-harvester/blob/db1ee42374c58575ddf1b38d7f3f4222c0c397f4/controllers/harvestercluster_controller.go#L573 . Server is looked up in the
cluster
section of the kubeconfig using thecurrent-context
value, which might be different than thecluster.name
matching it.More generally, the whole section of the code seems to lack checking against
nil
values, which might cause the Crash Loop.Environment: