summaryrefslogtreecommitdiff
path: root/pkg/spec/createconfig.go
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2019-03-28 17:39:56 -0400
committerMatthew Heon <mheon@redhat.com>2019-03-28 17:39:56 -0400
commitbeb263554efdb849291caf5dba4a74966564b78d (patch)
treecc701d33503fbc012cb03ef417dca916a91fac27 /pkg/spec/createconfig.go
parent9085898ce2d42bf872c137e981202820066736c7 (diff)
downloadpodman-beb263554efdb849291caf5dba4a74966564b78d.tar.gz
podman-beb263554efdb849291caf5dba4a74966564b78d.tar.bz2
podman-beb263554efdb849291caf5dba4a74966564b78d.zip
Ensure that we make a netns for CNI non-default nets
We accidentally patched this out trying to enable ns:/path/to/ns This should restore the ability to configure nondefault CNI networks with Podman, by ensuring that they request creation of a network namespace. Completely remove the WithNetNS() call when we do use an explicit namespace from a path. We use that call to indicate that a netns is going to be created - there should not be any question about whether it actually does. Fixes #2795 Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'pkg/spec/createconfig.go')
-rw-r--r--pkg/spec/createconfig.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/pkg/spec/createconfig.go b/pkg/spec/createconfig.go
index 07ae633d1..0a12e3dca 100644
--- a/pkg/spec/createconfig.go
+++ b/pkg/spec/createconfig.go
@@ -451,16 +451,15 @@ func (c *CreateConfig) GetContainerCreateOptions(runtime *libpod.Runtime, pod *l
}
}
- if IsNS(string(c.NetMode)) {
- split := strings.SplitN(string(c.NetMode), ":", 2)
- if len(split[0]) != 2 {
- return nil, errors.Errorf("invalid user defined network namespace %q", c.NetMode.UserDefined())
+ if c.NetMode.IsNS() {
+ ns := c.NetMode.NS()
+ if ns == "" {
+ return nil, errors.Errorf("invalid empty user-defined network namespace")
}
- _, err := os.Stat(split[1])
+ _, err := os.Stat(ns)
if err != nil {
return nil, err
}
- options = append(options, libpod.WithNetNS(portBindings, false, string(c.NetMode), networks))
} else if c.NetMode.IsContainer() {
connectedCtr, err := c.Runtime.LookupContainer(c.NetMode.Container())
if err != nil {