Skip to content

Commit 585f7ff

Browse files
author
Joshua Reed
committed
Should fix affinity group issue.
1 parent 9671a20 commit 585f7ff

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

controllers/cloudstackmachine_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (reconciler *CloudStackMachineReconciler) Reconcile(ctx context.Context, re
9090

9191
func (r *CloudStackMachineReconciliationRunner) Reconcile() (retRes ctrl.Result, reterr error) {
9292
return r.RunReconciliationStages(
93-
r.GetZones(r.Zones),
93+
r.GetZonesAndRequeueIfMissing(r.Zones),
9494
r.GetParent(r.ReconciliationSubject, r.CAPIMachine),
9595
r.RequeueIfCloudStackClusterNotReady,
9696
r.ConsiderAffinity,

controllers/utils/zones.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,16 @@ func (r *ReconciliationRunner) GetZones(zones *infrav1.CloudStackZoneList) Cloud
8181
return ctrl.Result{}, nil
8282
}
8383
}
84+
85+
// GetZonesAndRequeueIfMissing gets CloudStackZones owned by a CloudStackCluster via an ownership label, and requeues
86+
// if none are found.
87+
func (r *ReconciliationRunner) GetZonesAndRequeueIfMissing(zones *infrav1.CloudStackZoneList) CloudStackReconcilerMethod {
88+
return func() (ctrl.Result, error) {
89+
if res, err := r.GetZones(zones)(); r.ShouldReturn(res, err) {
90+
return res, err
91+
} else if len(zones.Items) < 1 {
92+
return r.RequeueWithMessage("no zones found, requeueing")
93+
}
94+
return ctrl.Result{}, nil
95+
}
96+
}

0 commit comments

Comments
 (0)