summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2021-08-23 11:00:55 +0200
committerMatthew Heon <mheon@redhat.com>2021-08-30 13:19:47 -0400
commit17afae4ebdc44fdea8f4dfccdd347e5a65804427 (patch)
tree93455e160eebe6701eb7e94527b6c4031b310025
parentc16daa07ed2ccb251d2eaf76614c8fde433dcc91 (diff)
downloadpodman-17afae4ebdc44fdea8f4dfccdd347e5a65804427.tar.gz
podman-17afae4ebdc44fdea8f4dfccdd347e5a65804427.tar.bz2
podman-17afae4ebdc44fdea8f4dfccdd347e5a65804427.zip
Use pod netns with --pod-id-file
When `--pod-id-file` is used do not parse the default network namespace and let specgen handle it instead. This regression was introduced in commit 7ef3981abe24. Fixes #11303 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
-rw-r--r--cmd/podman/containers/create.go2
-rw-r--r--cmd/podman/containers/run.go2
-rw-r--r--test/e2e/pod_create_test.go15
3 files changed, 17 insertions, 2 deletions
diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go
index c88cf050e..ba762ecbb 100644
--- a/cmd/podman/containers/create.go
+++ b/cmd/podman/containers/create.go
@@ -84,7 +84,7 @@ func create(cmd *cobra.Command, args []string) error {
var (
err error
)
- cliVals.Net, err = common.NetFlagsToNetOptions(cmd, cliVals.Pod == "")
+ cliVals.Net, err = common.NetFlagsToNetOptions(cmd, cliVals.Pod == "" && cliVals.PodIDFile == "")
if err != nil {
return err
}
diff --git a/cmd/podman/containers/run.go b/cmd/podman/containers/run.go
index 579af4eb1..830d1de7f 100644
--- a/cmd/podman/containers/run.go
+++ b/cmd/podman/containers/run.go
@@ -106,7 +106,7 @@ func init() {
func run(cmd *cobra.Command, args []string) error {
var err error
- cliVals.Net, err = common.NetFlagsToNetOptions(cmd, cliVals.Pod == "")
+ cliVals.Net, err = common.NetFlagsToNetOptions(cmd, cliVals.Pod == "" && cliVals.PodIDFile == "")
if err != nil {
return err
}
diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go
index 028689211..13c8d7ad4 100644
--- a/test/e2e/pod_create_test.go
+++ b/test/e2e/pod_create_test.go
@@ -117,6 +117,21 @@ var _ = Describe("Podman pod create", func() {
Expect(check).Should(Exit(0))
})
+ It("podman create pod with id file with network portbindings", func() {
+ file := filepath.Join(podmanTest.TempDir, "pod.id")
+ name := "test"
+ session := podmanTest.Podman([]string{"pod", "create", "--name", name, "--pod-id-file", file, "-p", "8080:80"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+
+ webserver := podmanTest.Podman([]string{"run", "--pod-id-file", file, "-dt", nginx})
+ webserver.WaitWithDefaultTimeout()
+ Expect(webserver).Should(Exit(0))
+
+ check := SystemExec("nc", []string{"-z", "localhost", "8080"})
+ Expect(check).Should(Exit(0))
+ })
+
It("podman create pod with no infra but portbindings should fail", func() {
name := "test"
session := podmanTest.Podman([]string{"pod", "create", "--infra=false", "--name", name, "-p", "80:80"})