Skip to content

Commit

Permalink
Skip config if policy not applied yet
Browse files Browse the repository at this point in the history
There is a stage when the SriovNetworkNodeState is initializing
where the spec is empty because the SriovNetworkNodePolicyReconciler
did not yet applied the policies.

It can cause a non required action by the plugins,
that will try to apply the empty spec by resetting the NIC for example.

The config daemon will not run the plugins if the generation is 1
and the Spec.Interfaces is empty.

Solves issue #283

For e2e tests, the wait timeout to get to initial Sync state has been
increased.
This change is needed as now the config daemon will not apply on "empty"
spec until the SriovNetworkNodePolicyReconciler will iterate on the Interfaces.
The reconcile loop interval is 5 minutes, so the test timeout needed to be increased.

Signed-off-by: Fred Rolland <[email protected]>
  • Loading branch information
rollandf committed Jul 10, 2022
1 parent 815fd13 commit bb60bfd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
5 changes: 5 additions & 0 deletions controllers/sriovnetworknodepolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ func (r *SriovNetworkNodePolicyReconciler) syncSriovNetworkNodeState(np *sriovne
return fmt.Errorf("failed to get SriovNetworkNodeState: %v", err)
}
} else {
if len(found.Status.Interfaces) == 0 {
logger.Info("SriovNetworkNodeState Status Interfaces are empty. Skip update of policies in spec")
return nil
}

logger.Info("SriovNetworkNodeState already exists, updating")
newVersion := found.DeepCopy()
newVersion.Spec = ns.Spec
Expand Down
13 changes: 13 additions & 0 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,19 @@ func (dn *Daemon) nodeStateSyncHandler(generation int64) error {
return nil
}

if latestState.GetGeneration() == 1 && len(latestState.Spec.Interfaces) == 0 {
glog.V(0).Infof("nodeStateSyncHandler(): Interface policy spec not yet set by controller")
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: "InProgress",
lastSyncError: "",
Expand Down
6 changes: 1 addition & 5 deletions test/e2e/e2e_tests_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ var quitNetNsSet chan bool
var doneNetNsSet chan error

// Define utility constants for object names and testing timeouts/durations and intervals.
const (
timeout = time.Second * 30
interval = time.Second * 1
devPollInterval = time.Millisecond * 400
)
const devPollInterval = time.Millisecond * 400

func TestSriovTests(t *testing.T) {
RegisterFailHandler(Fail)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/sriovoperatornodepolicy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var _ = Describe("Operator", func() {
Eventually(func() *cluster.EnabledNodes {
sriovInfos, _ = cluster.DiscoverSriov(clients, testNamespace)
return sriovInfos
}, timeout, interval).ShouldNot(BeNil())
}, Timeout*15, RetryInterval*20).ShouldNot(BeNil())
Expect(len(sriovInfos.Nodes)).To(BeNumerically(">", 0))

sriovIface, err = sriovInfos.FindOneSriovDevice(sriovInfos.Nodes[0])
Expand Down

0 comments on commit bb60bfd

Please sign in to comment.