From 9daecca581226a3efafb108cc721b30068b12030 Mon Sep 17 00:00:00 2001 From: Marcelo Guerrero Date: Mon, 30 Oct 2023 16:58:16 +0100 Subject: [PATCH] Trigger daemon reconcilation loop when status changes The sriov config daemon did not reconcile the VFs when users modified properties without using sriov policies. The status of the sriov network node state object was modified though, but this didn't trigger the start of the reconciliation loop. Signed-off-by: Marcelo Guerrero --- pkg/daemon/daemon.go | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/pkg/daemon/daemon.go b/pkg/daemon/daemon.go index 207685180c..104696b6ab 100644 --- a/pkg/daemon/daemon.go +++ b/pkg/daemon/daemon.go @@ -10,6 +10,7 @@ import ( "os" "os/exec" "path" + "reflect" "strconv" "strings" "sync" @@ -455,7 +456,27 @@ func (dn *Daemon) nodeStateSyncHandler() error { } } - if dn.nodeState.GetGeneration() == latest { + if latestState.GetGeneration() == 1 && len(latestState.Spec.Interfaces) == 0 { + err = dn.storeManager.ClearPCIAddressFolder() + if err != nil { + glog.Errorf("failed to clear the PCI address configuration: %v", err) + return err + } + + glog.V(0).Infof("nodeStateSyncHandler(): Name: %s, Interface policy spec not yet set by controller", latestState.Name) + if latestState.Status.SyncStatus != "Succeeded" { + dn.refreshCh <- Message{ + syncStatus: "Succeeded", + lastSyncError: "", + } + // wait for writer to refresh status + <-dn.syncCh + } + return nil + } + + // Do not reconcile if spec hasn't been updated or if status of interfaces have not been externally modified. + if dn.nodeState.GetGeneration() == latest && reflect.DeepEqual(dn.nodeState.Status.Interfaces, latestState.Status.Interfaces) { if dn.useSystemdService { serviceExist, err := dn.serviceManager.IsServiceExist(systemd.SriovServicePath) if err != nil { @@ -502,25 +523,6 @@ func (dn *Daemon) nodeStateSyncHandler() error { return nil } - if latestState.GetGeneration() == 1 && len(latestState.Spec.Interfaces) == 0 { - err = dn.storeManager.ClearPCIAddressFolder() - if err != nil { - glog.Errorf("failed to clear the PCI address configuration: %v", err) - return err - } - - glog.V(0).Infof("nodeStateSyncHandler(): Name: %s, Interface policy spec not yet set by controller", latestState.Name) - if latestState.Status.SyncStatus != "Succeeded" { - dn.refreshCh <- Message{ - syncStatus: "Succeeded", - lastSyncError: "", - } - // wait for writer to refresh status - <-dn.syncCh - } - return nil - } - dn.refreshCh <- Message{ syncStatus: syncStatusInProgress, lastSyncError: "",