From c711826996467eca662a6469881fccfc918cda05 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 20 Mar 2017 15:34:53 +0000 Subject: [PATCH] Blank out container ID when exec-ing a CNI ipam plugin to get bridge address --- plugin/net/cni.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugin/net/cni.go b/plugin/net/cni.go index fcf208fc..43eda246 100644 --- a/plugin/net/cni.go +++ b/plugin/net/cni.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "net" + "os" "strings" "syscall" @@ -87,6 +88,10 @@ func (c *CNIPlugin) CmdAdd(args *skel.CmdArgs) error { if err == weavenet.ErrBridgeNoIP { bridgeArgs := *args bridgeArgs.ContainerID = "weave:expose" + // It would be better if libcni let us send just the desired parameters, + // but there is a bug: https://github.com/containernetworking/cni/issues/410 + // so just blank out the one we want to change + os.Setenv("CNI_CONTAINERID", bridgeArgs.ContainerID) bridgeIPResult, err := c.getIP(conf.IPAM.Type, &bridgeArgs) if err != nil { return fmt.Errorf("unable to allocate IP address for bridge: %s", err)