@@ -107,7 +107,7 @@ func (reconciler *CloudStackMachineReconciler) Reconcile(ctx context.Context, re
107107 r := NewCSMachineReconciliationRunner ()
108108 r .UsingBaseReconciler (reconciler .ReconcilerBase ).ForRequest (req ).WithRequestCtx (ctx )
109109 r .WithAdditionalCommonStages (
110- r .GetParent (r .ReconciliationSubject , r .CAPIMachine ),
110+ r .RunIf ( func () bool { return r . ReconciliationSubject . GetDeletionTimestamp (). IsZero () }, r . GetParent (r .ReconciliationSubject , r .CAPIMachine ) ),
111111 r .RequeueIfCloudStackClusterNotReady ,
112112 r .SetFailureDomainOnCSMachine ,
113113 r .GetFailureDomainByName (func () string { return r .ReconciliationSubject .Spec .FailureDomainName }, r .FailureDomain ),
@@ -174,7 +174,8 @@ func (r *CloudStackMachineReconciliationRunner) ConsiderAffinity() (ctrl.Result,
174174func (r * CloudStackMachineReconciliationRunner ) SetFailureDomainOnCSMachine () (retRes ctrl.Result , reterr error ) {
175175 if r .ReconciliationSubject .Spec .FailureDomainName == "" {
176176 var name string
177- if r .CAPIMachine .Spec .FailureDomain != nil &&
177+ // CAPIMachine is null if it's been deleted but we're still reconciling the CS machine.
178+ if r .CAPIMachine != nil && r .CAPIMachine .Spec .FailureDomain != nil &&
178179 (util .IsControlPlaneMachine (r .CAPIMachine ) || // Is control plane machine -- CAPI will specify.
179180 * r .CAPIMachine .Spec .FailureDomain != "" ) { // Or potentially another machine controller specified.
180181 name = * r .CAPIMachine .Spec .FailureDomain
0 commit comments