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: "",