Skip to content

Commit e92061b

Browse files
Cloud Userkashifest
authored andcommitted
BMH pause annotation should be synced with CAPM3 machine
Signed-off-by: Kashif Khan <[email protected]>
1 parent ca341fd commit e92061b

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

controllers/metal3machine_controller.go

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -152,29 +152,23 @@ func (r *Metal3MachineReconciler) Reconcile(ctx context.Context, req ctrl.Reques
152152
}
153153

154154
// Check pause annotation on associated bmh (if any)
155-
if !cluster.Spec.Paused {
156-
err := machineMgr.RemovePauseAnnotation(ctx)
157-
if err != nil {
158-
machineLog.Info("failed to check pause annotation on associated bmh")
159-
conditions.MarkFalse(capm3Machine, infrav1.AssociateBMHCondition, infrav1.PauseAnnotationRemoveFailedReason, clusterv1.ConditionSeverityInfo, "")
160-
return ctrl.Result{}, nil
161-
}
162-
} else {
163-
// set pause annotation on associated bmh (if any)
155+
if annotations.IsPaused(cluster, capm3Machine) {
164156
err := machineMgr.SetPauseAnnotation(ctx)
165157
if err != nil {
166158
machineLog.Info("failed to set pause annotation on associated bmh")
167159
conditions.MarkFalse(capm3Machine, infrav1.AssociateBMHCondition, infrav1.PauseAnnotationSetFailedReason, clusterv1.ConditionSeverityInfo, "")
168160
return ctrl.Result{}, nil
169161
}
170-
}
171-
172-
// Return early if the M3Machine or Cluster is paused.
173-
if annotations.IsPaused(cluster, capm3Machine) {
174162
machineLog.Info("reconciliation is paused for this object")
175163
conditions.MarkFalse(capm3Machine, infrav1.AssociateBMHCondition, infrav1.Metal3MachinePausedReason, clusterv1.ConditionSeverityInfo, "")
176164
return ctrl.Result{Requeue: true, RequeueAfter: requeueAfter}, nil
177165
}
166+
err = machineMgr.RemovePauseAnnotation(ctx)
167+
if err != nil {
168+
machineLog.Info("failed to remove pause annotation on associated bmh")
169+
conditions.MarkFalse(capm3Machine, infrav1.AssociateBMHCondition, infrav1.PauseAnnotationRemoveFailedReason, clusterv1.ConditionSeverityInfo, "")
170+
return ctrl.Result{}, nil
171+
}
178172

179173
// Handle deleted machines
180174
if !capm3Machine.ObjectMeta.DeletionTimestamp.IsZero() {

test/e2e/pivoting.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ func RemoveDeployment(ctx context.Context, inputGetter func() RemoveDeploymentIn
334334
func labelBMOCRDs(ctx context.Context, targetCluster framework.ClusterProxy) {
335335
labels := map[string]string{}
336336
labels[clusterctlv1.ClusterctlLabel] = ""
337-
labels[clusterctlv1.ClusterctlMoveLabel] = ""
338337
labels[clusterctlv1.ClusterctlMoveHierarchyLabel] = ""
339338
labels[clusterv1.ProviderNameLabel] = "metal3"
340339
crdName := "baremetalhosts.metal3.io"
@@ -345,7 +344,8 @@ func labelBMOCRDs(ctx context.Context, targetCluster framework.ClusterProxy) {
345344
func labelHDCRDs(ctx context.Context, targetCluster framework.ClusterProxy) {
346345
labels := map[string]string{}
347346
labels[clusterctlv1.ClusterctlLabel] = ""
348-
labels[clusterctlv1.ClusterctlMoveLabel] = ""
347+
labels[clusterctlv1.ClusterctlMoveHierarchyLabel] = ""
348+
labels[clusterv1.ProviderNameLabel] = "metal3"
349349
crdName := "hardwaredata.metal3.io"
350350
err := LabelCRD(ctx, targetCluster.GetClient(), crdName, labels)
351351
Expect(err).ToNot(HaveOccurred(), "Cannot label HD CRDs")

0 commit comments

Comments
 (0)