Skip to content

Commit 5c8b919

Browse files
committed
clusterapi: check all machines are ready
Updates the post-machine-creation check so that all created machines, based on the applied manifests, are checked. Prior to this commit only the three master control-plane nodes were checked. This commit ensures the bootstrap machine is checked as well.
1 parent 974f1fd commit 5c8b919

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

pkg/infrastructure/clusterapi/clusterapi.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,23 +269,24 @@ func (i *InfraProvider) Provision(ctx context.Context, dir string, parents asset
269269
masterIgnSecret := IgnitionSecret(masterIgnAsset.Files()[0].Data, clusterID.InfraID, "master")
270270
machineManifests = append(machineManifests, bootstrapIgnSecret, masterIgnSecret)
271271

272-
timer.StartTimer(machineStage)
273272
// Create the machine manifests.
273+
timer.StartTimer(machineStage)
274+
machineNames := []string{}
275+
274276
for _, m := range machineManifests {
275277
m.SetNamespace(capiutils.Namespace)
276278
if err := cl.Create(ctx, m); err != nil {
277279
return fileList, fmt.Errorf("failed to create control-plane manifest: %w", err)
278280
}
279281
i.appliedManifests = append(i.appliedManifests, m)
282+
283+
if machine, ok := m.(*clusterv1.Machine); ok {
284+
machineNames = append(machineNames, machine.Name)
285+
}
280286
logrus.Infof("Created manifest %+T, namespace=%s name=%s", m, m.GetNamespace(), m.GetName())
281287
}
282288

283289
{
284-
masterCount := int64(1)
285-
if reps := installConfig.Config.ControlPlane.Replicas; reps != nil {
286-
masterCount = *reps
287-
}
288-
289290
untilTime := time.Now().Add(timeout)
290291
timezone, _ := untilTime.Zone()
291292
logrus.Infof("Waiting up to %v (until %v %s) for machines to provision...", timeout, untilTime.Format(time.Kitchen), timezone)
@@ -295,10 +296,10 @@ func (i *InfraProvider) Provision(ctx context.Context, dir string, parents asset
295296
Steps: 32,
296297
Cap: timeout,
297298
}, func(ctx context.Context) (bool, error) {
298-
for i := int64(0); i < masterCount; i++ {
299+
for _, machineName := range machineNames {
299300
machine := &clusterv1.Machine{}
300301
if err := cl.Get(ctx, client.ObjectKey{
301-
Name: fmt.Sprintf("%s-%s-%d", clusterID.InfraID, "master", i),
302+
Name: machineName,
302303
Namespace: capiutils.Namespace,
303304
}, machine); err != nil {
304305
if apierrors.IsNotFound(err) {

0 commit comments

Comments
 (0)