Skip to content

Commit 6ee4d9d

Browse files
committed
Add MP name label to DockerMachine to skip bootstrap
1 parent 4cea0d6 commit 6ee4d9d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

test/infrastructure/docker/exp/internal/controllers/dockermachinepool_controller.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func (r *DockerMachinePoolReconciler) reconcileNormal(ctx context.Context, clust
300300
}
301301

302302
// Create a DockerMachine for each instance returned by the node pool if it doesn't exist.
303-
if err := r.CreateDockerMachinesIfNotExists(ctx, dockerMachinePool, nodePoolInstancesResult); err != nil {
303+
if err := r.CreateDockerMachinesIfNotExists(ctx, machinePool, dockerMachinePool, nodePoolInstancesResult); err != nil {
304304
conditions.MarkFalse(dockerMachinePool, clusterv1.ReadyCondition, "FailedToCreateNewMachines", clusterv1.ConditionSeverityWarning, err.Error())
305305
return ctrl.Result{}, errors.Wrap(err, "failed to create missing machines")
306306
}
@@ -374,7 +374,7 @@ func (r *DockerMachinePoolReconciler) DeleteDanglingDockerMachines(ctx context.C
374374
}
375375

376376
// CreateDockerMachinesIfNotExists creates a DockerMachine for each instance returned by the node pool if it doesn't exist.
377-
func (r *DockerMachinePoolReconciler) CreateDockerMachinesIfNotExists(ctx context.Context, dockerMachinePool *infraexpv1.DockerMachinePool, instances []docker.NodePoolInstance) error {
377+
func (r *DockerMachinePoolReconciler) CreateDockerMachinesIfNotExists(ctx context.Context, machinePool *expv1.MachinePool, dockerMachinePool *infraexpv1.DockerMachinePool, instances []docker.NodePoolInstance) error {
378378
log := ctrl.LoggerFrom(ctx)
379379

380380
log.V(2).Info("Creating missing machines", "dockerMachinePool", dockerMachinePool.Name, "namespace", dockerMachinePool.Namespace, "instances", instances)
@@ -391,11 +391,13 @@ func (r *DockerMachinePoolReconciler) CreateDockerMachinesIfNotExists(ctx contex
391391

392392
for _, instance := range instances {
393393
if _, exists := instanceNameToDockerMachine[instance.InstanceName]; !exists {
394+
labels := dockerMachinePool.Status.InfrastructureMachineSelector.MatchLabels
395+
labels[clusterv1.MachinePoolNameLabel] = machinePool.Name
394396
dockerMachine := &infrav1.DockerMachine{
395397
ObjectMeta: metav1.ObjectMeta{
396398
Namespace: dockerMachinePool.Namespace,
397399
GenerateName: fmt.Sprintf("%s-", dockerMachinePool.Name),
398-
Labels: dockerMachinePool.Status.InfrastructureMachineSelector.MatchLabels,
400+
Labels: labels,
399401
Annotations: make(map[string]string),
400402
// Note: This DockerMachine will be owned by the DockerMachinePool until the MachinePool controller creates its parent Machine.
401403
},

test/infrastructure/docker/internal/controllers/dockermachine_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ func (r *DockerMachineReconciler) reconcileNormal(ctx context.Context, cluster *
223223
return ctrl.Result{}, nil
224224
}
225225

226+
// Be sure to include the MachinePool label in the DockerMachine along with the selector labels.
226227
_, machinePoolOwned := dockerMachine.Labels[clusterv1.MachinePoolNameLabel]
227228

228229
// if the machine is already provisioned, return

0 commit comments

Comments
 (0)