Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions internal/controller/controllers/bmh_agent_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,14 @@ func (r *BMACReconciler) reconcileBMH(ctx context.Context, log logrus.FieldLogge
dirty = true
}

if bmh.Spec.AutomatedCleaningMode != bmh_v1alpha1.CleaningModeDisabled {
// Disable AutomatedCleaningMode if the converged flow is not enabled
// since AutomatedCleaning requires IPA, but disabling the converged flow
// disables IPA.
bmh.Spec.AutomatedCleaningMode = bmh_v1alpha1.CleaningModeDisabled
dirty = true
}

proceed, stopReconcileLoop, requeuePeriod, reason := shouldReconcileBMH(bmh, infraEnv)

if !proceed {
Expand Down
26 changes: 20 additions & 6 deletions internal/controller/controllers/bmh_agent_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,22 +348,22 @@ var _ = Describe("bmac reconcile", func() {
Expect(host.ObjectMeta.Annotations[BMH_INSPECT_ANNOTATION]).To(Equal("disabled"))
Expect(host.Spec.AutomatedCleaningMode).To(Equal(bmh_v1alpha1.CleaningModeDisabled))

// Test that cleaning mode stays the same
// Test that cleaning mode is set to disabled
host.Spec.AutomatedCleaningMode = bmh_v1alpha1.CleaningModeMetadata
host.Status.Provisioning.State = bmh_v1alpha1.StateProvisioned

result = bmhr.reconcileBMH(ctx, bmhr.Log, host, nil, infraEnv)
Expect(result).To(Equal(reconcileComplete{dirty: false, stop: true}))
Expect(result).To(Equal(reconcileComplete{dirty: true, stop: true}))
Expect(host.ObjectMeta.Annotations).To(HaveKey(BMH_INSPECT_ANNOTATION))
Expect(host.ObjectMeta.Annotations[BMH_INSPECT_ANNOTATION]).To(Equal("disabled"))
Expect(host.Spec.AutomatedCleaningMode).To(Equal(bmh_v1alpha1.CleaningModeMetadata))
Expect(host.Spec.AutomatedCleaningMode).To(Equal(bmh_v1alpha1.CleaningModeDisabled))

// This should not return a dirty result because label is already set
result = bmhr.reconcileBMH(ctx, bmhr.Log, host, nil, infraEnv)
Expect(result).To(Equal(reconcileComplete{dirty: false, stop: true}))
Expect(host.ObjectMeta.Annotations).To(HaveKey(BMH_INSPECT_ANNOTATION))
Expect(host.ObjectMeta.Annotations[BMH_INSPECT_ANNOTATION]).To(Equal("disabled"))
Expect(host.Spec.AutomatedCleaningMode).To(Equal(bmh_v1alpha1.CleaningModeMetadata))
Expect(host.Spec.AutomatedCleaningMode).To(Equal(bmh_v1alpha1.CleaningModeDisabled))
})

It("should set the ISODownloadURL in the BMH", func() {
Expand All @@ -377,7 +377,20 @@ var _ = Describe("bmac reconcile", func() {
Expect(updatedHost.Spec.Image.URL).To(Equal(isoImageURL))
})

It("should not disable cleaning and set online true in the BMH", func() {
It("should disable cleaning and set online true in the BMH", func() {
result, err := bmhr.Reconcile(ctx, newBMHRequest(host))
Expect(err).To(BeNil())
Expect(result).To(Equal(ctrl.Result{}))

updatedHost := &bmh_v1alpha1.BareMetalHost{}
err = c.Get(ctx, types.NamespacedName{Name: "bmh-reconcile", Namespace: testNamespace}, updatedHost)
Expect(err).To(BeNil())
Expect(updatedHost.Spec.Online).To(Equal(true))
Expect(updatedHost.Spec.AutomatedCleaningMode).To(Equal(bmh_v1alpha1.CleaningModeDisabled))
})

It("should disable cleaning when set to metadata by user in the BMH", func() {
host.Spec.AutomatedCleaningMode = bmh_v1alpha1.CleaningModeMetadata
result, err := bmhr.Reconcile(ctx, newBMHRequest(host))
Expect(err).To(BeNil())
Expect(result).To(Equal(ctrl.Result{}))
Expand All @@ -386,8 +399,9 @@ var _ = Describe("bmac reconcile", func() {
err = c.Get(ctx, types.NamespacedName{Name: "bmh-reconcile", Namespace: testNamespace}, updatedHost)
Expect(err).To(BeNil())
Expect(updatedHost.Spec.Online).To(Equal(true))
Expect(updatedHost.Spec.AutomatedCleaningMode).NotTo(Equal(bmh_v1alpha1.CleaningModeDisabled))
Expect(updatedHost.Spec.AutomatedCleaningMode).To(Equal(bmh_v1alpha1.CleaningModeDisabled))
})

It("should not reconcile BMH if the updated image has not been around longer than the grace period", func() {
// Reconcile with the original ISO
_ = bmhr.reconcileBMH(ctx, bmhr.Log, host, nil, infraEnv)
Expand Down