mirror of
https://github.com/rancher/plugins.git
synced 2025-07-08 20:53:53 +00:00
fix bug on ipam revert if cmdAdd fails on macvlan and host-device
This commit is contained in:
parent
7df5acee0f
commit
214bcb8c8b
@ -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…
Reference in New Issue
Block a user