Blank out container ID when exec-ing a CNI ipam plugin to get bridge address

This commit is contained in:
Bryan Boreham authored and Marc Carré committed 2017-03-21 11:39:36 +00:00
1 parent eef6965590
commit c711826996
1 file changed
+5
+5
View File
@@ -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)