diff --git a/pkg/daemon/daemon.go b/pkg/daemon/daemon.go index b4d6d8ec55..ddca64c124 100644 --- a/pkg/daemon/daemon.go +++ b/pkg/daemon/daemon.go @@ -451,11 +451,7 @@ func (dn *Daemon) nodeStateSyncHandler(generation int64) error { reqDrain := false for k, p := range dn.enabledPlugins { d, r := false, false - if dn.nodeState.GetName() == "" { - d, r, err = p.OnNodeStateAdd(latestState) - } else { - d, r, err = p.OnNodeStateChange(dn.nodeState, latestState) - } + d, r, err = p.OnNodeStateChange(dn.nodeState, latestState) if err != nil { glog.Errorf("nodeStateSyncHandler(): plugin %s error: %v", k, err) return err diff --git a/pkg/plugins/generic/generic_plugin.go b/pkg/plugins/generic/generic_plugin.go index bd4ee35a68..9f7a928ccf 100644 --- a/pkg/plugins/generic/generic_plugin.go +++ b/pkg/plugins/generic/generic_plugin.go @@ -52,24 +52,7 @@ func (p *GenericPlugin) Spec() string { return p.SpecVersion } -// OnNodeStateAdd Invoked when SriovNetworkNodeState CR is created, return if need dain and/or reboot node -func (p *GenericPlugin) OnNodeStateAdd(state *sriovnetworkv1.SriovNetworkNodeState) (needDrain bool, needReboot bool, err error) { - glog.Info("generic-plugin OnNodeStateAdd()") - needDrain = false - needReboot = false - err = nil - p.DesireState = state - - needDrain = needDrainNode(state.Spec.Interfaces, state.Status.Interfaces) - needReboot = needRebootNode(state, &p.LoadVfioDriver) - - if needReboot { - needDrain = true - } - return -} - -// OnNodeStateChange Invoked when SriovNetworkNodeState CR is updated, return if need dain and/or reboot node +// OnNodeStateChange Invoked when SriovNetworkNodeState CR is created or updated, return if need dain and/or reboot node func (p *GenericPlugin) OnNodeStateChange(old, new *sriovnetworkv1.SriovNetworkNodeState) (needDrain bool, needReboot bool, err error) { glog.Info("generic-plugin OnNodeStateChange()") needDrain = false diff --git a/pkg/plugins/intel/intel_plugin.go b/pkg/plugins/intel/intel_plugin.go index 2d6de2eef5..1a1c77136d 100644 --- a/pkg/plugins/intel/intel_plugin.go +++ b/pkg/plugins/intel/intel_plugin.go @@ -33,13 +33,7 @@ func (p *IntelPlugin) Spec() string { return p.SpecVersion } -// OnNodeStateAdd Invoked when SriovNetworkNodeState CR is created, return if need dain and/or reboot node -func (p *IntelPlugin) OnNodeStateAdd(state *sriovnetworkv1.SriovNetworkNodeState) (needDrain bool, needReboot bool, err error) { - glog.Info("intel-plugin OnNodeStateAdd()") - return false, false, nil -} - -// OnNodeStateChange Invoked when SriovNetworkNodeState CR is updated, return if need dain and/or reboot node +// OnNodeStateChange Invoked when SriovNetworkNodeState CR is created or updated, return if need dain and/or reboot node func (p *IntelPlugin) OnNodeStateChange(old, new *sriovnetworkv1.SriovNetworkNodeState) (needDrain bool, needReboot bool, err error) { glog.Info("intel-plugin OnNodeStateChange()") return false, false, nil diff --git a/pkg/plugins/k8s/k8s_plugin.go b/pkg/plugins/k8s/k8s_plugin.go index f6ff4717d1..ad30310420 100644 --- a/pkg/plugins/k8s/k8s_plugin.go +++ b/pkg/plugins/k8s/k8s_plugin.go @@ -111,13 +111,7 @@ func (p *K8sPlugin) Spec() string { return p.SpecVersion } -// OnNodeStateAdd Invoked when SriovNetworkNodeState CR is created, return if need dain and/or reboot node -func (p *K8sPlugin) OnNodeStateAdd(state *sriovnetworkv1.SriovNetworkNodeState) (needDrain bool, needReboot bool, err error) { - glog.Info("k8s-plugin OnNodeStateAdd()") - return p.OnNodeStateChange(nil, state) -} - -// OnNodeStateChange Invoked when SriovNetworkNodeState CR is updated, return if need dain and/or reboot node +// OnNodeStateChange Invoked when SriovNetworkNodeState CR is created or updated, return if need dain and/or reboot node func (p *K8sPlugin) OnNodeStateChange(old, new *sriovnetworkv1.SriovNetworkNodeState) (needDrain bool, needReboot bool, err error) { glog.Info("k8s-plugin OnNodeStateChange()") needDrain = false diff --git a/pkg/plugins/mellanox/mellanox_plugin.go b/pkg/plugins/mellanox/mellanox_plugin.go index 9428acd385..97b2515abe 100644 --- a/pkg/plugins/mellanox/mellanox_plugin.go +++ b/pkg/plugins/mellanox/mellanox_plugin.go @@ -62,14 +62,7 @@ func (p *MellanoxPlugin) Spec() string { return p.SpecVersion } -// OnNodeStateAdd Invoked when SriovNetworkNodeState CR is created, return if need dain and/or reboot node -func (p *MellanoxPlugin) OnNodeStateAdd(state *sriovnetworkv1.SriovNetworkNodeState) (needDrain bool, needReboot bool, err error) { - glog.Info("mellanox-plugin OnNodeStateAdd()") - - return p.OnNodeStateChange(nil, state) -} - -// OnNodeStateChange Invoked when SriovNetworkNodeState CR is updated, return if need dain and/or reboot node +// OnNodeStateChange Invoked when SriovNetworkNodeState CR is created or updated, return if need dain and/or reboot node func (p *MellanoxPlugin) OnNodeStateChange(old, new *sriovnetworkv1.SriovNetworkNodeState) (needDrain bool, needReboot bool, err error) { glog.Info("mellanox-Plugin OnNodeStateChange()") diff --git a/pkg/plugins/plugin.go b/pkg/plugins/plugin.go index a1b3cc4327..5769ee3e99 100644 --- a/pkg/plugins/plugin.go +++ b/pkg/plugins/plugin.go @@ -9,9 +9,7 @@ type VendorPlugin interface { Name() string // Return the SpecVersion followed by plugin Spec() string - // Invoked when SriovNetworkNodeState CR is created, return if need dain and/or reboot node - OnNodeStateAdd(state *sriovnetworkv1.SriovNetworkNodeState) (bool, bool, error) - // Invoked when SriovNetworkNodeState CR is updated, return if need dain and/or reboot node + // Invoked when SriovNetworkNodeState CR is created or updated, return if need dain and/or reboot node OnNodeStateChange(old, new *sriovnetworkv1.SriovNetworkNodeState) (bool, bool, error) // Apply config change Apply() error diff --git a/pkg/plugins/virtual/virtual_plugin.go b/pkg/plugins/virtual/virtual_plugin.go index 06b0b9e3ba..10789df6bb 100644 --- a/pkg/plugins/virtual/virtual_plugin.go +++ b/pkg/plugins/virtual/virtual_plugin.go @@ -45,22 +45,7 @@ func (p *VirtualPlugin) Spec() string { return p.SpecVersion } -// OnNodeStateAdd Invoked when SriovNetworkNodeState CR is created, return if need dain and/or reboot node -func (p *VirtualPlugin) OnNodeStateAdd(state *sriovnetworkv1.SriovNetworkNodeState) (needDrain bool, needReboot bool, err error) { - glog.Info("virtual-plugin OnNodeStateAdd()") - needReboot = false - err = nil - p.DesireState = state - - if p.LoadVfioDriver != loaded { - if needVfioDriver(state) { - p.LoadVfioDriver = loading - } - } - return -} - -// OnNodeStateChange Invoked when SriovNetworkNodeState CR is updated, return if need dain and/or reboot node +// OnNodeStateChange Invoked when SriovNetworkNodeState CR is created or updated, return if need dain and/or reboot node func (p *VirtualPlugin) OnNodeStateChange(old, new *sriovnetworkv1.SriovNetworkNodeState) (needDrain bool, needReboot bool, err error) { glog.Info("virtual-plugin OnNodeStateChange()") needDrain = false