Skip to content

Commit

Permalink
Fix FimwareConfigMatchCondition update
Browse files Browse the repository at this point in the history
We need to update FimwareConfigMatchCondition condition if
FW or driver changed.

Signed-off-by: Ivan Kolodiazhnyi <[email protected]>
  • Loading branch information
e0ne committed Nov 8, 2024
1 parent 596843b commit 8bd4650
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions internal/controller/devicediscovery_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ func (d *DeviceDiscovery) reconcile(ctx context.Context) error {
continue
}

err = d.updateFwCondition(ctx, nicDeviceCR)
if err != nil {
log.Log.Error(err, "failed to update NicDevice FimwareConfigMatchCondition", "device", nicDeviceCR.Name)
continue
}

// Need to nullify conditions for deep equal
observedDeviceStatus.Conditions = nicDeviceCR.Status.Conditions

Expand Down Expand Up @@ -192,19 +198,29 @@ func (d *DeviceDiscovery) reconcile(ctx context.Context) error {
device.Status.Node = d.nodeName
setInitialsConditionsForDevice(device)

ofedVersion := d.hostManager.DiscoverOfedVersion()
recommendedFirmware := helper.GetRecommendedFwVersion(device.Status.Type, ofedVersion)
setFwConfigConditionsForDevice(device, recommendedFirmware)

err = d.Client.Status().Update(ctx, device)
err = d.updateFwCondition(ctx, *device)
if err != nil {
log.Log.Error(err, "failed to update NicDevice CR status", "device", deviceName)
log.Log.Error(err, "failed to update FimwareConfigMatchCondition", "device", device.Name)
continue
}
}
return nil
}

func (d *DeviceDiscovery) updateFwCondition(ctx context.Context, nicDeviceCR v1alpha1.NicDevice) error {
ofedVersion := d.hostManager.DiscoverOfedVersion()
recommendedFirmware := helper.GetRecommendedFwVersion(nicDeviceCR.Status.Type, ofedVersion)
setFwConfigConditionsForDevice(&nicDeviceCR, recommendedFirmware)

err := d.Client.Status().Update(ctx, &nicDeviceCR)
if err != nil {
log.Log.Error(err, "failed to update NicDevice FimwareConfigMatchCondition", "device", nicDeviceCR.Name)
return err
}

return nil
}

// Start starts the device discovery process by reconciling devices on the host.
//
// It triggers the first reconciliation manually and then runs it periodically based on the
Expand Down

0 comments on commit 8bd4650

Please sign in to comment.