Merge pull request #301 from mars1024/bugfix/ipam_revert
fix bug on ip revert if cmdAdd fails on macvlan and host-device
This commit is contained in:
commit
827a4bd843
@ -21,6 +21,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
@ -96,7 +97,9 @@ func cmdAdd(args *skel.CmdArgs) error {
|
|||||||
// Invoke ipam del if err to avoid ip leak
|
// Invoke ipam del if err to avoid ip leak
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
os.Setenv("CNI_COMMAND", "DEL")
|
||||||
ipam.ExecDel(cfg.IPAM.Type, args.StdinData)
|
ipam.ExecDel(cfg.IPAM.Type, args.StdinData)
|
||||||
|
os.Setenv("CNI_COMMAND", "ADD")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/j-keck/arping"
|
"github.com/j-keck/arping"
|
||||||
@ -197,7 +198,9 @@ func cmdAdd(args *skel.CmdArgs) error {
|
|||||||
// Invoke ipam del if err to avoid ip leak
|
// Invoke ipam del if err to avoid ip leak
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
os.Setenv("CNI_COMMAND", "DEL")
|
||||||
ipam.ExecDel(n.IPAM.Type, args.StdinData)
|
ipam.ExecDel(n.IPAM.Type, args.StdinData)
|
||||||
|
os.Setenv("CNI_COMMAND", "ADD")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user