Skip to content

Commit e5695cf

Browse files
author
Joshua Reed
committed
Initial attemtp. Testing now.
1 parent eb51b18 commit e5695cf

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

controllers/cloudstackmachine_controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ func (r *CloudStackMachineReconciliationRunner) SetFailureDomainOnCSMachine() (r
148148
return ctrl.Result{}, errors.Errorf("could not find zone by zoneName: %s", r.ReconciliationSubject.Spec.ZoneName)
149149
}
150150
} else { // No Zone Specified, pick a Random Zone.
151+
if len(r.Zones.Items) < 1 { // Double check that zones are present.
152+
return r.RequeueWithMessage("no zones found, requeueing")
153+
}
151154
randNum := (rand.Int() % len(r.Zones.Items)) // #nosec G404 -- weak crypt rand doesn't matter here.
152155
r.ReconciliationSubject.Status.ZoneID = r.Zones.Items[randNum].Spec.ID
153156
}

controllers/utils/zones.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ 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+
} else if len(zones.Items) < 1 {
79+
return r.RequeueWithMessage("no zones found, requeueing")
7880
}
7981
return ctrl.Result{}, nil
8082
}

0 commit comments

Comments
 (0)