Skip to content

Commit c0d5e8d

Browse files
authored
Merge pull request #129 from rejoshed/fixup/affinity-group-deletion
GetZonesAndRequeueIfMissing method added to fix affinity group deletion
2 parents 9671a20 + 6387049 commit c0d5e8d

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
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: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (r *ReconciliationRunner) CreateZones(zoneSpecs []infrav1.Zone) CloudStackR
6363
}
6464
}
6565

66-
// GetZones gets CloudStackZones owned by a CloudStackCluster via an ownership label.
66+
// GetZones gets CloudStackZones owned by a CloudStackCluster.
6767
func (r *ReconciliationRunner) GetZones(zones *infrav1.CloudStackZoneList) CloudStackReconcilerMethod {
6868
return func() (ctrl.Result, error) {
6969
capiClusterLabel := map[string]string{
@@ -75,6 +75,16 @@ func (r *ReconciliationRunner) GetZones(zones *infrav1.CloudStackZoneList) Cloud
7575
client.MatchingLabels(capiClusterLabel),
7676
); err != nil {
7777
return ctrl.Result{}, errors.Wrap(err, "failed to list zones")
78+
}
79+
return ctrl.Result{}, nil
80+
}
81+
}
82+
83+
// GetZonesAndRequeueIfMissing gets CloudStackZones owned by a CloudStackCluster and requeues if none are found.
84+
func (r *ReconciliationRunner) GetZonesAndRequeueIfMissing(zones *infrav1.CloudStackZoneList) CloudStackReconcilerMethod {
85+
return func() (ctrl.Result, error) {
86+
if res, err := r.GetZones(zones)(); r.ShouldReturn(res, err) {
87+
return res, err
7888
} else if len(zones.Items) < 1 {
7989
return r.RequeueWithMessage("no zones found, requeueing")
8090
}

0 commit comments

Comments
 (0)