diff --git a/pkg/ipam/ipam.go b/pkg/ipam/ipam.go index aeb25816..4463035d 100644 --- a/pkg/ipam/ipam.go +++ b/pkg/ipam/ipam.go @@ -16,10 +16,8 @@ package ipam import ( "context" - "fmt" "github.com/containernetworking/cni/pkg/invoke" "github.com/containernetworking/cni/pkg/types" - "os" ) func ExecAdd(plugin string, netconf []byte) (types.Result, error) { @@ -31,13 +29,5 @@ func ExecCheck(plugin string, netconf []byte) error { } func ExecDel(plugin string, netconf []byte) error { - cmd := os.Getenv("CNI_COMMAND") - if cmd == "" { - return fmt.Errorf("environment variable CNI_COMMAND must be specified.") - } - // Set CNI_COMMAND to DEL explicity. We might be deleting due to an ADD gone wrong. - // restore CNI_COMMAND to original value upon return. - os.Setenv("CNI_COMMAND", "DEL") - defer os.Setenv("CNI_COMMAND", cmd) return invoke.DelegateDel(context.TODO(), plugin, netconf, nil) } diff --git a/plugins/main/windows/win-bridge/win-bridge_windows.go b/plugins/main/windows/win-bridge/win-bridge_windows.go index 5b05e73a..d8a2d81b 100644 --- a/plugins/main/windows/win-bridge/win-bridge_windows.go +++ b/plugins/main/windows/win-bridge/win-bridge_windows.go @@ -19,7 +19,6 @@ import ( "fmt" "runtime" "strings" - "os" "github.com/Microsoft/hcsshim" "github.com/Microsoft/hcsshim/hcn" @@ -146,7 +145,7 @@ func cmdHcnAdd(args *skel.CmdArgs, n *NetConf) (*current.Result, error) { return nil, fmt.Errorf("network %v not found", networkName) } - if hcnNetwork.Type != hcn.L2Bridge { + if hcnNetwork.Type != hcn.L2Bridge { return nil, fmt.Errorf("network %v is of unexpected type: %v", networkName, hcnNetwork.Type) } @@ -191,13 +190,11 @@ func cmdAdd(args *skel.CmdArgs) error { } if err != nil { - os.Setenv("CNI_COMMAND", "DEL") ipam.ExecDel(n.IPAM.Type, args.StdinData) - os.Setenv("CNI_COMMAND", "ADD") return errors.Annotate(err, "error while executing ADD command") } - if (result == nil) { + if result == nil { return errors.New("result for ADD not populated correctly") } return types.PrintResult(result, cniVersion) diff --git a/plugins/main/windows/win-overlay/win-overlay_windows.go b/plugins/main/windows/win-overlay/win-overlay_windows.go index befd664f..0b6fa61f 100644 --- a/plugins/main/windows/win-overlay/win-overlay_windows.go +++ b/plugins/main/windows/win-overlay/win-overlay_windows.go @@ -19,7 +19,6 @@ import ( "fmt" "runtime" "strings" - "os" "github.com/Microsoft/hcsshim" "github.com/juju/errors" @@ -135,9 +134,7 @@ func cmdAdd(args *skel.CmdArgs) error { }) defer func() { if !success { - os.Setenv("CNI_COMMAND", "DEL") ipam.ExecDel(n.IPAM.Type, args.StdinData) - os.Setenv("CNI_COMMAND", "ADD") } }() if err != nil {