diff --git a/internal/controller/devicediscovery_controller.go b/internal/controller/devicediscovery_controller.go index 70964a6..b56aed2 100644 --- a/internal/controller/devicediscovery_controller.go +++ b/internal/controller/devicediscovery_controller.go @@ -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 @@ -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