From ea9dee8592d45ff43fb14f144ec13fa3c07feb36 Mon Sep 17 00:00:00 2001 From: Marcelo Guerrero Date: Thu, 26 Oct 2023 10:07:24 +0200 Subject: [PATCH] Remove LastState parameter of GenericPlugin 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. --- pkg/plugins/generic/generic_plugin.go | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/pkg/plugins/generic/generic_plugin.go b/pkg/plugins/generic/generic_plugin.go index 44069407e0..e21b0ff588 100644 --- a/pkg/plugins/generic/generic_plugin.go +++ b/pkg/plugins/generic/generic_plugin.go @@ -4,7 +4,6 @@ import ( "bytes" "errors" "os/exec" - "reflect" "strconv" "strings" "syscall" @@ -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 @@ -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 } @@ -180,8 +170,7 @@ func (p *GenericPlugin) Apply() error { } return err } - p.LastState = &sriovnetworkv1.SriovNetworkNodeState{} - *p.LastState = *p.DesireState + return nil }