Skip to content

Commit 461ea3f

Browse files
authored
Merge pull request #5434 from fabriziopandini/capd-show-missing-container
🌱 CAPD detects missing container
2 parents d2a110e + acd0ea1 commit 461ea3f

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

controllers/machine_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ func patchMachine(ctx context.Context, patchHelper *patch.Helper, machine *clust
206206
clusterv1.MachineHealthCheckSuccededCondition,
207207
clusterv1.MachineOwnerRemediatedCondition,
208208
),
209-
conditions.WithStepCounterIf(machine.ObjectMeta.DeletionTimestamp.IsZero()),
209+
conditions.WithStepCounterIf(machine.ObjectMeta.DeletionTimestamp.IsZero() && machine.Spec.ProviderID == nil),
210210
conditions.WithStepCounterIfOnly(
211211
clusterv1.BootstrapReadyCondition,
212212
clusterv1.InfrastructureReadyCondition,

test/infrastructure/docker/api/v1beta1/condition_consts.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ const (
4242
// an error while provisioning the container that provides the DockerMachine infrastructure; those kind of
4343
// errors are usually transient and failed provisioning are automatically re-tried by the controller.
4444
ContainerProvisioningFailedReason = "ContainerProvisioningFailed"
45+
46+
// ContainerDeletedReason (Severity=Error) documents a DockerMachine controller detecting
47+
// the underlying container has been deleted unexpectedly.
48+
ContainerDeletedReason = "ContainerDeleted"
4549
)
4650

4751
const (

test/infrastructure/docker/controllers/dockermachine_controller.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func patchDockerMachine(ctx context.Context, patchHelper *patch.Helper, dockerMa
169169
infrav1.ContainerProvisionedCondition,
170170
infrav1.BootstrapExecSucceededCondition,
171171
),
172-
conditions.WithStepCounterIf(dockerMachine.ObjectMeta.DeletionTimestamp.IsZero()),
172+
conditions.WithStepCounterIf(dockerMachine.ObjectMeta.DeletionTimestamp.IsZero() && dockerMachine.Spec.ProviderID == nil),
173173
)
174174

175175
// Patch the object, ignoring conflicts on the conditions owned by this controller.
@@ -192,7 +192,12 @@ func (r *DockerMachineReconciler) reconcileNormal(ctx context.Context, cluster *
192192
// ensure ready state is set.
193193
// This is required after move, because status is not moved to the target cluster.
194194
dockerMachine.Status.Ready = true
195-
conditions.MarkTrue(dockerMachine, infrav1.ContainerProvisionedCondition)
195+
196+
if externalMachine.Exists() {
197+
conditions.MarkTrue(dockerMachine, infrav1.ContainerProvisionedCondition)
198+
} else {
199+
conditions.MarkFalse(dockerMachine, infrav1.ContainerProvisionedCondition, infrav1.ContainerDeletedReason, clusterv1.ConditionSeverityError, fmt.Sprintf("Container %s does not exists anymore", externalMachine.Name()))
200+
}
196201
return ctrl.Result{}, nil
197202
}
198203

0 commit comments

Comments
 (0)