@@ -124,21 +124,16 @@ func (r *ReconciliationRunner) SetupLogger() (res ctrl.Result, retErr error) {
124
124
return ctrl.Result {}, nil
125
125
}
126
126
127
- func (r * ReconciliationRunner ) IfDeletionTimestampIsZero (fn CloudStackReconcilerMethod ) CloudStackReconcilerMethod {
128
- return func () (ctrl.Result , error ) {
129
- r .Log .V (1 ).Info ("Checking for deletion timestamp." )
130
- if r .ConditionalResult = r .ReconciliationSubject .GetDeletionTimestamp ().IsZero (); r .ConditionalResult {
131
- return fn ()
132
- }
133
- return ctrl.Result {}, nil
134
- }
135
- }
136
-
137
127
// RunIf accepts a conditional method and CloudStackReconcilerMethod and runs the CloudStackBaseContext if the conditional
138
128
// method is true.
139
129
func (r * ReconciliationRunner ) RunIf (conditional func () bool , fn CloudStackReconcilerMethod ) CloudStackReconcilerMethod {
140
130
return func () (ctrl.Result , error ) {
141
- if r .ConditionalResult = conditional (); r .ConditionalResult {
131
+ // Set conditional post stage since the interim stage may change it.
132
+ placeholder := conditional ()
133
+ defer func () {
134
+ r .ConditionalResult = placeholder
135
+ }()
136
+ if placeholder {
142
137
return fn ()
143
138
}
144
139
return ctrl.Result {}, nil
@@ -148,6 +143,8 @@ func (r *ReconciliationRunner) RunIf(conditional func() bool, fn CloudStackRecon
148
143
func (r * ReconciliationRunner ) Else (fn CloudStackReconcilerMethod ) CloudStackReconcilerMethod {
149
144
return func () (ctrl.Result , error ) {
150
145
if ! r .ConditionalResult {
146
+ r .Log .Info ("Deleting ASDF." )
147
+ fmt .Println (r .ConditionalResult )
151
148
return fn ()
152
149
}
153
150
return ctrl.Result {}, nil
@@ -351,7 +348,7 @@ func (r *ReconciliationRunner) RunBaseReconciliationStages() (res ctrl.Result, r
351
348
r .RequeueIfMissingBaseCRs }
352
349
baseStages = append (
353
350
append (baseStages , r .additionalCommonStages ... ),
354
- r .IfDeletionTimestampIsZero ( r .Reconcile ),
351
+ r .RunIf ( func () bool { return r . ReconciliationSubject . GetDeletionTimestamp (). IsZero () }, r .Reconcile ),
355
352
r .Else (r .ReconcileDelete ))
356
353
357
354
return r .RunReconciliationStages (baseStages ... )
@@ -436,9 +433,7 @@ func (r *ReconciliationRunner) NewChildObjectMeta(name string) metav1.ObjectMeta
436
433
// actually fetched and reques if not. The base reconciliation stages will continue even if not so as to allow deletion.
437
434
func (r * ReconciliationRunner ) RequeueIfMissingBaseCRs () (ctrl.Result , error ) {
438
435
r .Log .V (1 ).Info ("Requeueing if missing ReconciliationSubject, CloudStack cluster, or CAPI cluster." )
439
- if r .ReconciliationSubject .GetName () == "" {
440
- return r .RequeueWithMessage ("Reconciliation subject wasn't found. Requeueing." )
441
- } else if r .CSCluster .GetName () == "" {
436
+ if r .CSCluster .GetName () == "" {
442
437
return r .RequeueWithMessage ("CloudStackCluster wasn't found. Requeueing." )
443
438
} else if r .CAPICluster .GetName () == "" {
444
439
return r .RequeueWithMessage ("CAPI Cluster wasn't found. Requeueing." )
0 commit comments