From a525cbbf8c9b44c4fb87545970bd04b1afd28fbc Mon Sep 17 00:00:00 2001 From: Aaron Francis Fernandes <79958509+aaronfern@users.noreply.github.com> Date: Mon, 17 Feb 2025 21:03:10 +0530 Subject: [PATCH] Add a nil check before trying to adding mc annotation (#966) (#967) --- pkg/controller/deployment.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/controller/deployment.go b/pkg/controller/deployment.go index ba4dd8d0b..862723d02 100644 --- a/pkg/controller/deployment.go +++ b/pkg/controller/deployment.go @@ -636,6 +636,9 @@ func (dc *controller) setMachinePriorityAnnotationAndUpdateTriggeredForDeletion( continue } mcAdjust := mc.DeepCopy() + if mcAdjust.Annotations == nil { + mcAdjust.Annotations = make(map[string]string) + } mcAdjust.Annotations[machineutils.MachinePriority] = "1" _, err = dc.controlMachineClient.Machines(mcAdjust.Namespace).Update(ctx, mcAdjust, metav1.UpdateOptions{}) if err != nil {