Skip to content

Commit

Permalink
Merge pull request #323 from e0ne/issues/322
Browse files Browse the repository at this point in the history
Fix drain logic after node reboot
  • Loading branch information
SchSeba authored Jun 28, 2022
2 parents 547dd51 + 5796b5d commit 815fd13
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions pkg/plugins/generic/generic_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,24 +166,26 @@ func isCommandNotFound(err error) bool {
}

func needDrainNode(desired sriovnetworkv1.Interfaces, current sriovnetworkv1.InterfaceExts) (needDrain bool) {
glog.V(2).Infof("generic-plugin needDrainNode(): current state '%+v', desired state '%+v'", current, desired)
needDrain = false
for _, ifaceStatus := range current {
configured := false
for _, iface := range desired {
if iface.PciAddress == ifaceStatus.PciAddress {
// TODO: no need to perform further checks if ifaceStatus.NumVfs equals to 0
// once https://github.com/kubernetes/kubernetes/issues/109595 will be fixed
configured = true
if ifaceStatus.NumVfs != 0 {
if iface.NumVfs != ifaceStatus.NumVfs {
glog.V(2).Infof("generic-plugin needDrainNode(): need drain, expect NumVfs %v, current NumVfs %v", iface.NumVfs, ifaceStatus.NumVfs)
needDrain = true
return
}
if iface.Mtu != 0 && iface.Mtu != ifaceStatus.Mtu {
glog.V(2).Infof("generic-plugin needDrainNode(): need drain, expect MTU %v, current MTU %v", iface.Mtu, ifaceStatus.Mtu)
needDrain = true
return
}
if iface.NumVfs != ifaceStatus.NumVfs {
glog.V(2).Infof("generic-plugin needDrainNode(): need drain, expect NumVfs %v, current NumVfs %v", iface.NumVfs, ifaceStatus.NumVfs)
needDrain = true
return
}
if iface.Mtu != 0 && iface.Mtu != ifaceStatus.Mtu {
glog.V(2).Infof("generic-plugin needDrainNode(): need drain, expect MTU %v, current MTU %v", iface.Mtu, ifaceStatus.Mtu)
needDrain = true
return
}
glog.V(2).Infof("generic-plugin needDrainNode(): no need drain, expect NumVfs %v, current NumVfs %v", iface.NumVfs, ifaceStatus.NumVfs)
}
}
if !configured && ifaceStatus.NumVfs > 0 {
Expand Down

0 comments on commit 815fd13

Please sign in to comment.