Skip to content

Commit 48f1df6

Browse files
Ensure nil-pointer check in KCP syncMachines
Signed-off-by: killianmuldoon <[email protected]>
1 parent 333fd2c commit 48f1df6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

controlplane/kubeadm/internal/controllers/controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,10 @@ func (r *KubeadmControlPlaneReconciler) syncMachines(ctx context.Context, contro
598598
return errors.Wrapf(err, "failed to update InfrastructureMachine %s", klog.KObj(infraMachine))
599599
}
600600

601-
kubeadmConfig := controlPlane.KubeadmConfigs[machineName]
601+
kubeadmConfig, ok := controlPlane.GetKubeadmConfig(machineName)
602+
if !ok || kubeadmConfig == nil {
603+
return errors.Wrapf(err, "failed to retrieve KubeadmConfig for machine %s", machineName)
604+
}
602605
// Note: Set the GroupVersionKind because updateExternalObject depends on it.
603606
kubeadmConfig.SetGroupVersionKind(m.Spec.Bootstrap.ConfigRef.GroupVersionKind())
604607
// Cleanup managed fields of all KubeadmConfigs to drop ownership of labels and annotations

0 commit comments

Comments
 (0)