Skip to content

Commit d50f243

Browse files
authored
Merge pull request #12438 from sivchari/stop-using-deprecated-status
⚠️ Stop using v1beta1 status in CAPD controllers
2 parents 17b5d2a + b2046fd commit d50f243

File tree

6 files changed

+75
-108
lines changed

6 files changed

+75
-108
lines changed

test/infrastructure/docker/internal/controllers/backends/docker/dockercluster_backend.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ func (r *ClusterBackEndReconciler) ReconcileDelete(ctx context.Context, cluster
142142

143143
// Set the LoadBalancerAvailableCondition reporting delete is started, and requeue in order to make
144144
// this visible to the users.
145-
// TODO (v1beta2): test for v1beta2 conditions
146-
if v1beta1conditions.GetReason(dockerCluster, infrav1.LoadBalancerAvailableV1Beta1Condition) != clusterv1.DeletingV1Beta1Reason {
145+
if conditions.GetReason(dockerCluster, infrav1.DevClusterDockerLoadBalancerAvailableCondition) != infrav1.DevClusterDockerLoadBalancerDeletingReason {
147146
v1beta1conditions.MarkFalse(dockerCluster, infrav1.LoadBalancerAvailableV1Beta1Condition, clusterv1.DeletingV1Beta1Reason, clusterv1.ConditionSeverityInfo, "")
148147
conditions.Set(dockerCluster, metav1.Condition{
149148
Type: infrav1.DevClusterDockerLoadBalancerAvailableCondition,

test/infrastructure/docker/internal/controllers/backends/docker/dockermachine_backend.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ func (r *MachineBackendReconciler) ReconcileNormal(ctx context.Context, cluster
133133
// In this case recover the information from the existing v1beta1 condition, because we do not know if
134134
// all commands succeeded.
135135
if !conditions.Has(dockerMachine, infrav1.DevMachineDockerContainerBootstrapExecSucceededCondition) {
136-
condition := v1beta1conditions.Get(dockerMachine, infrav1.BootstrapExecSucceededV1Beta1Condition)
137-
if condition == nil || condition.Status == corev1.ConditionTrue {
136+
condition := conditions.Get(dockerMachine, infrav1.DevMachineDockerContainerBootstrapExecSucceededCondition)
137+
if condition == nil || condition.Status == metav1.ConditionTrue {
138138
conditions.Set(dockerMachine, metav1.Condition{
139139
Type: infrav1.DevMachineDockerContainerBootstrapExecSucceededCondition,
140140
Status: metav1.ConditionTrue,
@@ -228,9 +228,8 @@ func (r *MachineBackendReconciler) ReconcileNormal(ctx context.Context, cluster
228228
}
229229

230230
// Update the ContainerProvisioned and BootstrapExecSucceeded condition if not already in the correct state.
231-
// TODO (v1beta2): test for v1beta2 conditions
232231
requeue := false
233-
if !v1beta1conditions.IsTrue(dockerMachine, infrav1.ContainerProvisionedV1Beta1Condition) {
232+
if !conditions.IsTrue(dockerMachine, infrav1.DevMachineDockerContainerProvisionedCondition) {
234233
v1beta1conditions.MarkTrue(dockerMachine, infrav1.ContainerProvisionedV1Beta1Condition)
235234
conditions.Set(dockerMachine, metav1.Condition{
236235
Type: infrav1.DevMachineDockerContainerProvisionedCondition,
@@ -239,7 +238,7 @@ func (r *MachineBackendReconciler) ReconcileNormal(ctx context.Context, cluster
239238
})
240239
requeue = true
241240
}
242-
if !v1beta1conditions.Has(dockerMachine, infrav1.BootstrapExecSucceededV1Beta1Condition) {
241+
if !conditions.Has(dockerMachine, infrav1.DevMachineDockerContainerBootstrapExecSucceededCondition) {
243242
v1beta1conditions.MarkFalse(dockerMachine, infrav1.BootstrapExecSucceededV1Beta1Condition, infrav1.BootstrappingV1Beta1Reason, clusterv1.ConditionSeverityInfo, "")
244243
conditions.Set(dockerMachine, metav1.Condition{
245244
Type: infrav1.DevMachineDockerContainerBootstrapExecSucceededCondition,
@@ -425,8 +424,7 @@ func (r *MachineBackendReconciler) ReconcileDelete(ctx context.Context, cluster
425424
// this visible to the users.
426425
// NB. The operation in docker is fast, so there is the chance the user will not notice the status change;
427426
// nevertheless we are issuing a patch so we can test a pattern that will be used by other providers as well
428-
// TODO (v1beta2): test for v1beta2 conditions
429-
if v1beta1conditions.GetReason(dockerMachine, infrav1.ContainerProvisionedV1Beta1Condition) != clusterv1.DeletingV1Beta1Reason {
427+
if conditions.GetReason(dockerMachine, infrav1.DevMachineDockerContainerProvisionedCondition) != infrav1.DevMachineDockerContainerDeletingReason {
430428
v1beta1conditions.MarkFalse(dockerMachine, infrav1.ContainerProvisionedV1Beta1Condition, clusterv1.DeletingV1Beta1Reason, clusterv1.ConditionSeverityInfo, "")
431429
conditions.Set(dockerCluster, metav1.Condition{
432430
Type: infrav1.DevMachineDockerContainerProvisionedCondition,

test/infrastructure/docker/internal/controllers/backends/inmemory/inmemorymachine_backend.go

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,7 @@ func (r *MachineBackendReconciler) reconcileNormalCloudMachine(ctx context.Conte
242242

243243
func (r *MachineBackendReconciler) reconcileNormalNode(ctx context.Context, cluster *clusterv1.Cluster, machine *clusterv1.Machine, inMemoryMachine *infrav1.DevMachine) (_ ctrl.Result, retErr error) {
244244
// No-op if the VM is not provisioned yet
245-
// TODO (v1beta2): test for v1beta2 conditions
246-
if !v1beta1conditions.IsTrue(inMemoryMachine, infrav1.VMProvisionedCondition) {
245+
if !conditions.IsTrue(inMemoryMachine, infrav1.DevMachineInMemoryVMProvisionedCondition) {
247246
conditions.Set(inMemoryMachine, metav1.Condition{
248247
Type: infrav1.DevMachineInMemoryNodeProvisionedCondition,
249248
Status: metav1.ConditionFalse,
@@ -280,8 +279,7 @@ func (r *MachineBackendReconciler) reconcileNormalNode(ctx context.Context, clus
280279
}
281280
}
282281

283-
// TODO (v1beta2): test for v1beta2 conditions
284-
start := v1beta1conditions.Get(inMemoryMachine, infrav1.VMProvisionedCondition).LastTransitionTime
282+
start := conditions.Get(inMemoryMachine, infrav1.DevMachineInMemoryVMProvisionedCondition).LastTransitionTime
285283
now := time.Now()
286284
if now.Before(start.Add(provisioningDuration)) {
287285
v1beta1conditions.MarkFalse(inMemoryMachine, infrav1.NodeProvisionedCondition, infrav1.NodeWaitingForStartupTimeoutReason, clusterv1.ConditionSeverityInfo, "")
@@ -374,8 +372,7 @@ func (r *MachineBackendReconciler) reconcileNormalETCD(ctx context.Context, clus
374372
}
375373

376374
// No-op if the VM is not provisioned yet
377-
// TODO (v1beta2): test for v1beta2 conditions
378-
if !v1beta1conditions.IsTrue(inMemoryMachine, infrav1.VMProvisionedCondition) {
375+
if !conditions.IsTrue(inMemoryMachine, infrav1.DevMachineInMemoryVMProvisionedCondition) {
379376
conditions.Set(inMemoryMachine, metav1.Condition{
380377
Type: infrav1.DevMachineInMemoryEtcdProvisionedCondition,
381378
Status: metav1.ConditionFalse,
@@ -385,8 +382,7 @@ func (r *MachineBackendReconciler) reconcileNormalETCD(ctx context.Context, clus
385382
}
386383

387384
// No-op if the Node is not provisioned yet
388-
// TODO (v1beta2): test for v1beta2 conditions
389-
if !v1beta1conditions.IsTrue(inMemoryMachine, infrav1.NodeProvisionedCondition) {
385+
if !conditions.IsTrue(inMemoryMachine, infrav1.DevMachineInMemoryNodeProvisionedCondition) {
390386
conditions.Set(inMemoryMachine, metav1.Condition{
391387
Type: infrav1.DevMachineInMemoryEtcdProvisionedCondition,
392388
Status: metav1.ConditionFalse,
@@ -423,8 +419,7 @@ func (r *MachineBackendReconciler) reconcileNormalETCD(ctx context.Context, clus
423419
}
424420
}
425421

426-
// TODO (v1beta2): test for v1beta2 conditions
427-
start := v1beta1conditions.Get(inMemoryMachine, infrav1.NodeProvisionedCondition).LastTransitionTime
422+
start := conditions.Get(inMemoryMachine, infrav1.DevMachineInMemoryNodeProvisionedCondition).LastTransitionTime
428423
now := time.Now()
429424
if now.Before(start.Add(provisioningDuration)) {
430425
v1beta1conditions.MarkFalse(inMemoryMachine, infrav1.EtcdProvisionedCondition, infrav1.EtcdWaitingForStartupTimeoutReason, clusterv1.ConditionSeverityInfo, "")
@@ -618,8 +613,7 @@ func (r *MachineBackendReconciler) reconcileNormalAPIServer(ctx context.Context,
618613
}
619614

620615
// No-op if the VM is not provisioned yet
621-
// TODO (v1beta2): test for v1beta2 conditions
622-
if !v1beta1conditions.IsTrue(inMemoryMachine, infrav1.VMProvisionedCondition) {
616+
if !conditions.IsTrue(inMemoryMachine, infrav1.DevMachineInMemoryVMProvisionedCondition) {
623617
conditions.Set(inMemoryMachine, metav1.Condition{
624618
Type: infrav1.DevMachineInMemoryAPIServerProvisionedCondition,
625619
Status: metav1.ConditionFalse,
@@ -629,8 +623,7 @@ func (r *MachineBackendReconciler) reconcileNormalAPIServer(ctx context.Context,
629623
}
630624

631625
// No-op if the Node is not provisioned yet
632-
// TODO (v1beta2): test for v1beta2 conditions
633-
if !v1beta1conditions.IsTrue(inMemoryMachine, infrav1.NodeProvisionedCondition) {
626+
if !conditions.IsTrue(inMemoryMachine, infrav1.DevMachineInMemoryNodeProvisionedCondition) {
634627
conditions.Set(inMemoryMachine, metav1.Condition{
635628
Type: infrav1.DevMachineInMemoryAPIServerProvisionedCondition,
636629
Status: metav1.ConditionFalse,
@@ -667,8 +660,7 @@ func (r *MachineBackendReconciler) reconcileNormalAPIServer(ctx context.Context,
667660
}
668661
}
669662

670-
// TODO (v1beta2): test for v1beta2 conditions
671-
start := v1beta1conditions.Get(inMemoryMachine, infrav1.NodeProvisionedCondition).LastTransitionTime
663+
start := conditions.Get(inMemoryMachine, infrav1.DevMachineInMemoryNodeProvisionedCondition).LastTransitionTime
672664
now := time.Now()
673665
if now.Before(start.Add(provisioningDuration)) {
674666
v1beta1conditions.MarkFalse(inMemoryMachine, infrav1.APIServerProvisionedCondition, infrav1.APIServerWaitingForStartupTimeoutReason, clusterv1.ConditionSeverityInfo, "")
@@ -775,8 +767,7 @@ func (r *MachineBackendReconciler) reconcileNormalScheduler(ctx context.Context,
775767
// specific behaviour for this component because they are not relevant for stress tests.
776768
// As a current approximation, we create the scheduler as soon as the API server is provisioned;
777769
// also, the scheduler is immediately marked as ready.
778-
// TODO (v1beta2): test for v1beta2 conditions
779-
if !v1beta1conditions.IsTrue(inMemoryMachine, infrav1.APIServerProvisionedCondition) {
770+
if !conditions.IsTrue(inMemoryMachine, infrav1.DevMachineInMemoryAPIServerProvisionedCondition) {
780771
return ctrl.Result{}, nil
781772
}
782773

@@ -823,8 +814,7 @@ func (r *MachineBackendReconciler) reconcileNormalControllerManager(ctx context.
823814
// specific behaviour for this component because they are not relevant for stress tests.
824815
// As a current approximation, we create the controller manager as soon as the API server is provisioned;
825816
// also, the controller manager is immediately marked as ready.
826-
// TODO (v1beta2): test for v1beta2 conditions
827-
if !v1beta1conditions.IsTrue(inMemoryMachine, infrav1.APIServerProvisionedCondition) {
817+
if !conditions.IsTrue(inMemoryMachine, infrav1.DevMachineInMemoryAPIServerProvisionedCondition) {
828818
return ctrl.Result{}, nil
829819
}
830820

0 commit comments

Comments
 (0)