Skip to content

Commit

Permalink
Merge pull request containernetworking#301 from mars1024/bugfix/ipam_…
Browse files Browse the repository at this point in the history
…revert

fix bug on ip revert if cmdAdd fails on macvlan and host-device
  • Loading branch information
dcbw committed Apr 24, 2019
2 parents 6975500 + 214bcb8 commit 827a4bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plugins/main/host-device/host-device.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"io/ioutil"
"net"
"os"
"path/filepath"
"runtime"
"strings"
Expand Down Expand Up @@ -96,7 +97,9 @@ func cmdAdd(args *skel.CmdArgs) error {
// Invoke ipam del if err to avoid ip leak
defer func() {
if err != nil {
os.Setenv("CNI_COMMAND", "DEL")
ipam.ExecDel(cfg.IPAM.Type, args.StdinData)
os.Setenv("CNI_COMMAND", "ADD")
}
}()

Expand Down
3 changes: 3 additions & 0 deletions plugins/main/macvlan/macvlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"errors"
"fmt"
"net"
"os"
"runtime"

"github.com/j-keck/arping"
Expand Down Expand Up @@ -197,7 +198,9 @@ func cmdAdd(args *skel.CmdArgs) error {
// Invoke ipam del if err to avoid ip leak
defer func() {
if err != nil {
os.Setenv("CNI_COMMAND", "DEL")
ipam.ExecDel(n.IPAM.Type, args.StdinData)
os.Setenv("CNI_COMMAND", "ADD")
}
}()

Expand Down

0 comments on commit 827a4bd

Please sign in to comment.