Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix HFC Status #1825

Merged
merged 1 commit into from
Jul 30, 2024
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
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)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we don't need the same generation check here because all conditions are updated together, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

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