Skip to content

Commit

Permalink
Trigger daemon reconcilation loop when status changes
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mlguerrero12 committed Oct 31, 2023
1 parent ea9dee8 commit 091f7dc
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"os/exec"
"path"
"reflect"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -464,7 +465,29 @@ 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 {
log.Log.Error(err, "failed to clear the PCI address configuration")
return err
}

log.Log.V(0).Info(
"nodeStateSyncHandler(): interface policy spec not yet set by controller for sriovNetworkNodeState",
"name", 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 {
Expand Down Expand Up @@ -511,27 +534,6 @@ func (dn *Daemon) nodeStateSyncHandler() error {
return nil
}

if latestState.GetGeneration() == 1 && len(latestState.Spec.Interfaces) == 0 {
err = dn.storeManager.ClearPCIAddressFolder()
if err != nil {
log.Log.Error(err, "failed to clear the PCI address configuration")
return err
}

log.Log.V(0).Info(
"nodeStateSyncHandler(): interface policy spec not yet set by controller for sriovNetworkNodeState",
"name", 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: "",
Expand Down

0 comments on commit 091f7dc

Please sign in to comment.