Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

call ipam.ExecDel after clean up device in netns #702

Merged
merged 1 commit into from
Mar 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions plugins/main/bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down