From d4716bf91430f6e6fc326817e3d43b167ed3ce77 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 propertities 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 reconcilation loop. Signed-off-by: Marcelo Guerrero --- pkg/daemon/daemon.go | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/pkg/daemon/daemon.go b/pkg/daemon/daemon.go index 207685180c..4385c7960f 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,26 @@ 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 + } + + 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 +522,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: "",