@@ -19,11 +19,12 @@ package controllers
19
19
import (
20
20
"context"
21
21
"fmt"
22
- "k8s.io/utils/pointer"
23
22
"math/rand"
24
23
"reflect"
25
24
"regexp"
26
25
26
+ "k8s.io/utils/pointer"
27
+
27
28
"github.com/pkg/errors"
28
29
corev1 "k8s.io/api/core/v1"
29
30
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -105,7 +106,7 @@ func (reconciler *CloudStackMachineReconciler) Reconcile(ctx context.Context, re
105
106
r := NewCSMachineReconciliationRunner ()
106
107
r .UsingBaseReconciler (reconciler .ReconcilerBase ).ForRequest (req ).WithRequestCtx (ctx )
107
108
r .WithAdditionalCommonStages (
108
- r .GetParent (r .ReconciliationSubject , r .CAPIMachine ),
109
+ r .RunIf ( func () bool { return r . ReconciliationSubject . GetDeletionTimestamp (). IsZero () }, r . GetParent (r .ReconciliationSubject , r .CAPIMachine ) ),
109
110
r .RequeueIfCloudStackClusterNotReady ,
110
111
r .SetFailureDomainOnCSMachine ,
111
112
r .GetFailureDomainByName (func () string { return r .ReconciliationSubject .Spec .FailureDomainName }, r .FailureDomain ),
@@ -158,7 +159,8 @@ func (r *CloudStackMachineReconciliationRunner) ConsiderAffinity() (ctrl.Result,
158
159
func (r * CloudStackMachineReconciliationRunner ) SetFailureDomainOnCSMachine () (retRes ctrl.Result , reterr error ) {
159
160
if r .ReconciliationSubject .Spec .FailureDomainName == "" {
160
161
var name string
161
- if r .CAPIMachine .Spec .FailureDomain != nil &&
162
+ // CAPIMachine is null if it's been deleted but we're still reconciling the CS machine.
163
+ if r .CAPIMachine != nil && r .CAPIMachine .Spec .FailureDomain != nil &&
162
164
(util .IsControlPlaneMachine (r .CAPIMachine ) || // Is control plane machine -- CAPI will specify.
163
165
* r .CAPIMachine .Spec .FailureDomain != "" ) { // Or potentially another machine controller specified.
164
166
name = * r .CAPIMachine .Spec .FailureDomain
0 commit comments