Merge pull request #702 from gojoy/master

call ipam.ExecDel after clean up device in netns
This commit is contained in:
Dan Williams 2022-03-02 10:50:25 -06:00 committed by GitHub
commit b8a10bbe11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -631,14 +631,17 @@ func cmdDel(args *skel.CmdArgs) error {
isLayer3 := n.IPAM.Type != ""
if isLayer3 {
if err := ipam.ExecDel(n.IPAM.Type, args.StdinData); err != nil {
return err
ipamDel := func() error {
if isLayer3 {
if err := ipam.ExecDel(n.IPAM.Type, args.StdinData); err != nil {
return err
}
}
return nil
}
if args.Netns == "" {
return nil
return ipamDel()
}
// There is a netns so try to clean up. Delete can be called multiple times
@ -660,11 +663,16 @@ func cmdDel(args *skel.CmdArgs) error {
// https://github.com/kubernetes/kubernetes/issues/43014#issuecomment-287164444
_, ok := err.(ns.NSPathNotExistErr)
if ok {
return nil
return ipamDel()
}
return err
}
// call ipam.ExecDel after clean up device in netns
if err := ipamDel(); err != nil {
return err
}
if n.MacSpoofChk {
sc := link.NewSpoofChecker("", "", uniqueID(args.ContainerID, args.IfName))
if err := sc.Teardown(); err != nil {