Skip to content

Commit ec5de8f

Browse files
author
Joshua Reed
committed
Some fixup.
1 parent f31eecb commit ec5de8f

File tree

4 files changed

+15
-21
lines changed

4 files changed

+15
-21
lines changed

controllers/cloudstackcluster_controller.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ func (reconciler *CloudStackClusterReconciler) Reconcile(ctx context.Context, re
8686
// Reconcile actually reconciles the CloudStackCluster.
8787
func (r *CloudStackClusterReconciliationRunner) Reconcile() (res ctrl.Result, reterr error) {
8888
return r.RunReconciliationStages(
89-
r.RequeueIfMissingBaseCRs,
9089
r.CreateFailureDomains(r.ReconciliationSubject.Spec.FailureDomains),
9190
r.CheckOwnedCRDsForReadiness(infrav1.GroupVersion.WithKind("CloudStackFailureDomain")),
9291
r.GetFailureDomains(r.FailureDomains),

controllers/cloudstackmachine_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (r *CloudStackMachineReconciliationRunner) Reconcile() (retRes ctrl.Result,
105105
r.GetOrCreateVMInstance,
106106
r.RequeueIfInstanceNotRunning,
107107
r.AddToLBIfNeeded,
108-
r.GetOrCreateMachineStateChecker,
108+
// r.GetOrCreateMachineStateChecker,
109109
)
110110
}
111111

controllers/utils/base_reconciler.go

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -124,21 +124,16 @@ func (r *ReconciliationRunner) SetupLogger() (res ctrl.Result, retErr error) {
124124
return ctrl.Result{}, nil
125125
}
126126

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-
137127
// RunIf accepts a conditional method and CloudStackReconcilerMethod and runs the CloudStackBaseContext if the conditional
138128
// method is true.
139129
func (r *ReconciliationRunner) RunIf(conditional func() bool, fn CloudStackReconcilerMethod) CloudStackReconcilerMethod {
140130
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 {
142137
return fn()
143138
}
144139
return ctrl.Result{}, nil
@@ -148,6 +143,8 @@ func (r *ReconciliationRunner) RunIf(conditional func() bool, fn CloudStackRecon
148143
func (r *ReconciliationRunner) Else(fn CloudStackReconcilerMethod) CloudStackReconcilerMethod {
149144
return func() (ctrl.Result, error) {
150145
if !r.ConditionalResult {
146+
r.Log.Info("Deleting ASDF.")
147+
fmt.Println(r.ConditionalResult)
151148
return fn()
152149
}
153150
return ctrl.Result{}, nil
@@ -351,7 +348,7 @@ func (r *ReconciliationRunner) RunBaseReconciliationStages() (res ctrl.Result, r
351348
r.RequeueIfMissingBaseCRs}
352349
baseStages = append(
353350
append(baseStages, r.additionalCommonStages...),
354-
r.IfDeletionTimestampIsZero(r.Reconcile),
351+
r.RunIf(func() bool { return r.ReconciliationSubject.GetDeletionTimestamp().IsZero() }, r.Reconcile),
355352
r.Else(r.ReconcileDelete))
356353

357354
return r.RunReconciliationStages(baseStages...)
@@ -436,9 +433,7 @@ func (r *ReconciliationRunner) NewChildObjectMeta(name string) metav1.ObjectMeta
436433
// actually fetched and reques if not. The base reconciliation stages will continue even if not so as to allow deletion.
437434
func (r *ReconciliationRunner) RequeueIfMissingBaseCRs() (ctrl.Result, error) {
438435
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() == "" {
442437
return r.RequeueWithMessage("CloudStackCluster wasn't found. Requeueing.")
443438
} else if r.CAPICluster.GetName() == "" {
444439
return r.RequeueWithMessage("CAPI Cluster wasn't found. Requeueing.")

main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,10 @@ func setupReconcilers(base utils.ReconcilerBase, mgr manager.Manager) {
194194
setupLog.Error(err, "unable to create controller", "controller", "CloudStackMachine")
195195
os.Exit(1)
196196
}
197-
if err := (&controllers.CloudStackMachineStateCheckerReconciler{ReconcilerBase: base}).SetupWithManager(mgr); err != nil {
198-
setupLog.Error(err, "unable to create controller", "controller", "CloudStackMachineStateChecker")
199-
os.Exit(1)
200-
}
197+
// if err := (&controllers.CloudStackMachineStateCheckerReconciler{ReconcilerBase: base}).SetupWithManager(mgr); err != nil {
198+
// setupLog.Error(err, "unable to create controller", "controller", "CloudStackMachineStateChecker")
199+
// os.Exit(1)
200+
// }
201201
if err := (&controllers.CloudStackIsoNetReconciler{ReconcilerBase: base}).SetupWithManager(mgr); err != nil {
202202
setupLog.Error(err, "unable to create controller", "controller", "CloudStackIsoNetReconciler")
203203
os.Exit(1)

0 commit comments

Comments
 (0)