Skip to content

Commit

Permalink
Merge pull request #1825 from iurygregory/fix-hfc-component-info
Browse files Browse the repository at this point in the history
🐛 Fix HFC Status
  • Loading branch information
metal3-io-bot authored Jul 30, 2024
2 parents 12df962 + a62a169 commit efae71e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 7 additions & 5 deletions controllers/metal3.io/baremetalhost_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,10 @@ func (r *BareMetalHostReconciler) actionPreparing(prov provisioner.Provisioner,
info.log.Info("handling cleaning error in controller")
clearHostProvisioningSettings(info.host)
}
if hfcDirty {
info.log.Info("handling cleaning error during firmware update")
hfc.Status.Updates = nil
}
return recordActionFailure(info, metal3api.PreparationError, provResult.ErrorMessage)
}

Expand Down Expand Up @@ -1764,9 +1768,7 @@ func (r *BareMetalHostReconciler) saveHostFirmwareComponents(prov provisioner.Pr
info.log.Info("saving hostFirmwareComponents information", "spec updates", hfc.Spec.Updates, "status updates", hfc.Status.Updates)

hfc.Status.Updates = make([]metal3api.FirmwareUpdate, len(hfc.Spec.Updates))
for i := range hfc.Spec.Updates {
hfc.Spec.Updates[i].DeepCopyInto(&hfc.Status.Updates[i])
}
hfc.Status.Updates = hfc.Spec.Updates

// Retrieve new information about the firmware components stored in ironic
components, err := prov.GetFirmwareComponents()
Expand Down Expand Up @@ -1902,8 +1904,8 @@ func (r *BareMetalHostReconciler) getHostFirmwareComponents(info *reconcileInfo)
return false, nil, nil
}

// Check if there are Updates in the Spec that are different than the Status
if meta.IsStatusConditionTrue(hfc.Status.Conditions, string(metal3api.HostFirmwareComponentsChangeDetected)) {
// Check if the condition matches the current Generation to know if the data is not out of date.
if readyCond := meta.FindStatusCondition(hfc.Status.Conditions, string(metal3api.HostFirmwareComponentsChangeDetected)); readyCond != nil && readyCond.Status == metav1.ConditionTrue && readyCond.ObservedGeneration == hfc.Generation {
if meta.IsStatusConditionTrue(hfc.Status.Conditions, string(metal3api.HostFirmwareComponentsValid)) {
info.log.Info("hostFirmwareComponents indicating ChangeDetected", "namespacename", info.request.NamespacedName)
return true, hfc, nil
Expand Down
6 changes: 6 additions & 0 deletions controllers/metal3.io/hostfirmwarecomponents_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ func (r *HostFirmwareComponentsReconciler) updateHostFirmware(info *rhfcInfo, co
generation := info.hfc.GetGeneration()

newStatus := info.hfc.Status.DeepCopy()
// Check if there is mismatch between ironic information for components and Status.
componentInfoMismatch := !reflect.DeepEqual(info.hfc.Status.Components, components)
newStatus.Components = components

if updatesMismatch {
Expand All @@ -218,6 +220,10 @@ func (r *HostFirmwareComponentsReconciler) updateHostFirmware(info *rhfcInfo, co
}
}

if componentInfoMismatch {
dirty = true
}

// Update Status if has changed
if dirty {
info.log.Info("Status for HostFirmwareComponents changed")
Expand Down

0 comments on commit efae71e

Please sign in to comment.