diff --git a/controllers/metal3.io/baremetalhost_controller.go b/controllers/metal3.io/baremetalhost_controller.go index fd8c7b9210..2d8327fa76 100644 --- a/controllers/metal3.io/baremetalhost_controller.go +++ b/controllers/metal3.io/baremetalhost_controller.go @@ -1360,32 +1360,27 @@ func (r *BareMetalHostReconciler) actionDeprovisioning(prov provisioner.Provisio func (r *BareMetalHostReconciler) checkServicing(prov provisioner.Provisioner, info *reconcileInfo, hup *metal3api.HostUpdatePolicy) (result actionResult, isServicing bool) { servicingData := provisioner.ServicingData{} - var fwDirty bool - var hfsDirty bool - // (NOTE)janders: since Servicing is an opt-in feature that requires HostUpdatePolicy to be created and set to onReboot // set below booleans to false by default and change to true based on policy settings - servicingData.LiveFirmwareUpdateAllowed = false - servicingData.LiveFirmwareSettingsAllowed = false + var fwDirty bool + var hfsDirty bool + var LiveFirmwareUpdatesAllowed bool + var LiveFirmwareSettingsAllowed bool if hup != nil { - if hup.Spec.FirmwareSettings == metal3api.HostUpdatePolicyOnReboot { - servicingData.LiveFirmwareSettingsAllowed = true - } - if hup.Spec.FirmwareUpdates == metal3api.HostUpdatePolicyOnReboot { - servicingData.LiveFirmwareUpdateAllowed = true - } + LiveFirmwareUpdatesAllowed = (hup.Spec.FirmwareUpdates == metal3api.HostUpdatePolicyOnReboot) + LiveFirmwareSettingsAllowed = (hup.Spec.FirmwareSettings == metal3api.HostUpdatePolicyOnReboot) } - if servicingData.LiveFirmwareUpdateAllowed { + if LiveFirmwareUpdatesAllowed { if !reflect.DeepEqual(info.host.Status.Provisioning.Firmware, info.host.Spec.Firmware) { servicingData.FirmwareConfig = info.host.Spec.Firmware fwDirty = true } } - if servicingData.LiveFirmwareSettingsAllowed { + if LiveFirmwareSettingsAllowed { var hfs *metal3api.HostFirmwareSettings var err error hfsDirty, hfs, err = r.getHostFirmwareSettings(info) diff --git a/controllers/metal3.io/baremetalhost_controller_test.go b/controllers/metal3.io/baremetalhost_controller_test.go index 771fb3c0c8..6f6291569c 100644 --- a/controllers/metal3.io/baremetalhost_controller_test.go +++ b/controllers/metal3.io/baremetalhost_controller_test.go @@ -812,7 +812,23 @@ func TestRebootWithServicing(t *testing.T) { } host.Status.Provisioning.Image.URL = "foo" - r := newTestReconciler(host) + // HUP creation + hup := &metal3api.HostUpdatePolicy{ + TypeMeta: metav1.TypeMeta{ + Kind: "HostUpdatePolicy", + APIVersion: "metal3.io/v1alpha1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: host.Name, + Namespace: namespace, + }, + Spec: metal3api.HostUpdatePolicySpec{ + FirmwareSettings: metal3api.HostUpdatePolicyOnReboot, + FirmwareUpdates: metal3api.HostUpdatePolicyOnReboot, + }, + } + + r := newTestReconciler(host, hup) tryReconcile(t, r, host, func(host *metal3api.BareMetalHost, result reconcile.Result) bool {