Skip to content

Commit e9eff7f

Browse files
committed
fix nil pointer
1 parent 9d319ed commit e9eff7f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

azure/scope/machinepool.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,12 @@ func (m *MachinePoolScope) applyAzureMachinePoolMachines(ctx context.Context) er
421421
if machine != nil && machine.Annotations != nil {
422422
if _, hasDeleteAnnotation := machine.Annotations[clusterv1.DeleteMachineAnnotation]; hasDeleteAnnotation {
423423
log.V(4).Info("propagating DeleteMachineAnnotation", "machine", ampm.Spec.ProviderID)
424-
existingMachinesByProviderID[ampm.Spec.ProviderID].Annotations[clusterv1.DeleteMachineAnnotation] = machine.Annotations[clusterv1.DeleteMachineAnnotation]
424+
if ampm.Annotations == nil {
425+
ampm.Annotations = make(map[string]string)
426+
}
427+
ampm.Annotations[clusterv1.DeleteMachineAnnotation] = machine.Annotations[clusterv1.DeleteMachineAnnotation]
428+
// reassign
429+
existingMachinesByProviderID[ampm.Spec.ProviderID] = ampm
425430
}
426431
}
427432
}

0 commit comments

Comments
 (0)