Skip to content

Commit

Permalink
Remove LastState parameter of GenericPlugin
Browse files Browse the repository at this point in the history
The generic plugin was applying config changes only if
the desired spec of interfaces was different from the last
applied spec. This logic is different from the one in
OnNodeStateChange where the real status of the interfaces is
used to detect changes.

By removing the LastState parameter (and related code), the
generic plugin will also use the real status of interfaces
to decide whether to apply changes or not. The SyncNodeState
function has this logic.
  • Loading branch information
mlguerrero12 committed Nov 1, 2023
1 parent 744ca04 commit bbb5ddd
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions pkg/plugins/generic/generic_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"errors"
"os/exec"
"reflect"
"strconv"
"strings"
"syscall"
Expand Down Expand Up @@ -51,7 +50,6 @@ type GenericPlugin struct {
PluginName string
SpecVersion string
DesireState *sriovnetworkv1.SriovNetworkNodeState
LastState *sriovnetworkv1.SriovNetworkNodeState
DriverStateMap DriverStateMapType
DesiredKernelArgs map[string]bool
RunningOnHost bool
Expand Down Expand Up @@ -144,14 +142,6 @@ func (p *GenericPlugin) syncDriverState() error {
func (p *GenericPlugin) Apply() error {
log.Log.Info("generic-plugin Apply()", "desiredState", p.DesireState.Spec)

if p.LastState != nil {
log.Log.Info("generic-plugin Apply()", "lastState", p.LastState.Spec)
if reflect.DeepEqual(p.LastState.Spec.Interfaces, p.DesireState.Spec.Interfaces) {
log.Log.Info("generic-plugin Apply(): desired and latest state are the same, nothing to apply")
return nil
}
}

if err := p.syncDriverState(); err != nil {
return err
}
Expand Down Expand Up @@ -180,8 +170,7 @@ func (p *GenericPlugin) Apply() error {
}
return err
}
p.LastState = &sriovnetworkv1.SriovNetworkNodeState{}
*p.LastState = *p.DesireState

return nil
}

Expand Down

0 comments on commit bbb5ddd

Please sign in to comment.