From 15345ce4c3b02389fe172f090549a50b95322753 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Sat, 17 Oct 2020 06:44:34 -0400 Subject: podman create doesn't support creating detached containers Detached containers and detach keys are only created with the podman run, i exec, and start commands. We do not store the detach key sequence or the detach flags in the database, nor does Docker. The current code was ignoreing these fields but documenting that they can be used. Fix podman create man page and --help output to no longer indicate that --detach and --detach-keys works. Signed-off-by: Daniel J Walsh --- test/e2e/attach_test.go | 4 ++-- test/e2e/create_test.go | 18 ++++++++++++++++++ test/e2e/generate_systemd_test.go | 4 ++-- test/e2e/init_test.go | 10 +++++----- test/e2e/logs_test.go | 2 +- test/e2e/pod_rm_test.go | 2 +- test/e2e/ps_test.go | 2 +- test/e2e/restart_test.go | 2 +- test/e2e/run_networking_test.go | 2 +- test/e2e/run_volume_test.go | 2 +- test/e2e/start_test.go | 14 +++++++------- test/e2e/stop_test.go | 2 +- test/e2e/systemd_test.go | 2 +- test/system/250-systemd.bats | 2 +- 14 files changed, 43 insertions(+), 25 deletions(-) (limited to 'test') diff --git a/test/e2e/attach_test.go b/test/e2e/attach_test.go index 8065f6298..0c27e05c7 100644 --- a/test/e2e/attach_test.go +++ b/test/e2e/attach_test.go @@ -40,7 +40,7 @@ var _ = Describe("Podman attach", func() { }) It("podman attach to non-running container", func() { - session := podmanTest.Podman([]string{"create", "--name", "test1", "-d", "-i", ALPINE, "ls"}) + session := podmanTest.Podman([]string{"create", "--name", "test1", "-i", ALPINE, "ls"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -50,7 +50,7 @@ var _ = Describe("Podman attach", func() { }) It("podman container attach to non-running container", func() { - session := podmanTest.Podman([]string{"container", "create", "--name", "test1", "-d", "-i", ALPINE, "ls"}) + session := podmanTest.Podman([]string{"container", "create", "--name", "test1", "-i", ALPINE, "ls"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go index 96a234446..6b0f7a7af 100644 --- a/test/e2e/create_test.go +++ b/test/e2e/create_test.go @@ -626,4 +626,22 @@ var _ = Describe("Podman create", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(BeZero()) }) + + It("podman create -d should fail, can not detach create containers", func() { + session := podmanTest.Podman([]string{"create", "-d", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(125)) + Expect(session.ErrorToString()).To(ContainSubstring("unknown shorthand flag")) + + session = podmanTest.Podman([]string{"create", "--detach", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(125)) + Expect(session.ErrorToString()).To(ContainSubstring("unknown flag")) + + session = podmanTest.Podman([]string{"create", "--detach-keys", "ctrl-x", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(125)) + Expect(session.ErrorToString()).To(ContainSubstring("unknown flag")) + }) + }) diff --git a/test/e2e/generate_systemd_test.go b/test/e2e/generate_systemd_test.go index da2f67754..765844265 100644 --- a/test/e2e/generate_systemd_test.go +++ b/test/e2e/generate_systemd_test.go @@ -244,7 +244,7 @@ var _ = Describe("Podman generate systemd", func() { }) It("podman generate systemd --new with explicit detaching param in middle", func() { - n := podmanTest.Podman([]string{"create", "--name", "foo", "-d", "alpine", "top"}) + n := podmanTest.Podman([]string{"create", "--name", "foo", "alpine", "top"}) n.WaitWithDefaultTimeout() Expect(n.ExitCode()).To(Equal(0)) @@ -253,7 +253,7 @@ var _ = Describe("Podman generate systemd", func() { Expect(session.ExitCode()).To(Equal(0)) // Grepping the output (in addition to unit tests) - found, _ := session.GrepString("--name foo -d alpine top") + found, _ := session.GrepString("--name foo alpine top") Expect(found).To(BeTrue()) }) diff --git a/test/e2e/init_test.go b/test/e2e/init_test.go index baa5c5717..3e64cfda2 100644 --- a/test/e2e/init_test.go +++ b/test/e2e/init_test.go @@ -45,7 +45,7 @@ var _ = Describe("Podman init", func() { }) It("podman init single container by ID", func() { - session := podmanTest.Podman([]string{"create", "-d", ALPINE, "ls"}) + session := podmanTest.Podman([]string{"create", ALPINE, "ls"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) cid := session.OutputToString() @@ -61,7 +61,7 @@ var _ = Describe("Podman init", func() { It("podman init single container by name", func() { name := "test1" - session := podmanTest.Podman([]string{"create", "--name", name, "-d", ALPINE, "ls"}) + session := podmanTest.Podman([]string{"create", "--name", name, ALPINE, "ls"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) init := podmanTest.Podman([]string{"init", name}) @@ -76,7 +76,7 @@ var _ = Describe("Podman init", func() { It("podman init latest container", func() { SkipIfRemote("--latest flag n/a") - session := podmanTest.Podman([]string{"create", "-d", ALPINE, "ls"}) + session := podmanTest.Podman([]string{"create", ALPINE, "ls"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) init := podmanTest.Podman([]string{"init", "--latest"}) @@ -90,10 +90,10 @@ var _ = Describe("Podman init", func() { }) It("podman init all three containers, one running", func() { - session := podmanTest.Podman([]string{"create", "--name", "test1", "-d", ALPINE, "ls"}) + session := podmanTest.Podman([]string{"create", "--name", "test1", ALPINE, "ls"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session2 := podmanTest.Podman([]string{"create", "--name", "test2", "-d", ALPINE, "ls"}) + session2 := podmanTest.Podman([]string{"create", "--name", "test2", ALPINE, "ls"}) session2.WaitWithDefaultTimeout() Expect(session2.ExitCode()).To(Equal(0)) session3 := podmanTest.Podman([]string{"run", "--name", "test3", "-d", ALPINE, "top"}) diff --git a/test/e2e/logs_test.go b/test/e2e/logs_test.go index 664d4831e..4214bd50e 100644 --- a/test/e2e/logs_test.go +++ b/test/e2e/logs_test.go @@ -148,7 +148,7 @@ var _ = Describe("Podman logs", func() { }) It("podman logs on a created container should result in 0 exit code", func() { - session := podmanTest.Podman([]string{"create", "-dt", "--name", "log", ALPINE}) + session := podmanTest.Podman([]string{"create", "-t", "--name", "log", ALPINE}) session.WaitWithDefaultTimeout() Expect(session).To(Exit(0)) diff --git a/test/e2e/pod_rm_test.go b/test/e2e/pod_rm_test.go index 24643e6b2..24e945d5a 100644 --- a/test/e2e/pod_rm_test.go +++ b/test/e2e/pod_rm_test.go @@ -167,7 +167,7 @@ var _ = Describe("Podman pod rm", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"create", "-d", "--pod", podid1, ALPINE, "ls"}) + session = podmanTest.Podman([]string{"create", "--pod", podid1, ALPINE, "ls"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go index c65738993..11d0b8c9b 100644 --- a/test/e2e/ps_test.go +++ b/test/e2e/ps_test.go @@ -324,7 +324,7 @@ var _ = Describe("Podman ps", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"create", "-dt", ALPINE, "top"}) + session = podmanTest.Podman([]string{"create", "-t", ALPINE, "top"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) diff --git a/test/e2e/restart_test.go b/test/e2e/restart_test.go index 789b4dee5..114bd481a 100644 --- a/test/e2e/restart_test.go +++ b/test/e2e/restart_test.go @@ -54,7 +54,7 @@ var _ = Describe("Podman restart", func() { }) It("Podman restart stopped container by ID", func() { - session := podmanTest.Podman([]string{"create", "-d", ALPINE, "ls"}) + session := podmanTest.Podman([]string{"create", ALPINE, "ls"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) cid := session.OutputToString() diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go index 540ac5409..bd04e3090 100644 --- a/test/e2e/run_networking_test.go +++ b/test/e2e/run_networking_test.go @@ -357,7 +357,7 @@ var _ = Describe("Podman run networking", func() { }) It("podman run network expose ports in image metadata", func() { - session := podmanTest.Podman([]string{"create", "--name", "test", "-dt", "-P", nginx}) + session := podmanTest.Podman([]string{"create", "--name", "test", "-t", "-P", nginx}) session.Wait(90) Expect(session.ExitCode()).To(Equal(0)) results := podmanTest.Podman([]string{"inspect", "test"}) diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go index 92d3418e3..1c8a67123 100644 --- a/test/e2e/run_volume_test.go +++ b/test/e2e/run_volume_test.go @@ -489,7 +489,7 @@ VOLUME /test/` Expect(err).To(Not(BeNil())) // Make sure modifications in container disappear when container is stopped - session = podmanTest.Podman([]string{"create", "-d", "-v", fmt.Sprintf("%s:/run/test:O", mountPath), ALPINE, "top"}) + session = podmanTest.Podman([]string{"create", "-v", fmt.Sprintf("%s:/run/test:O", mountPath), ALPINE, "top"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) session = podmanTest.Podman([]string{"start", "-l"}) diff --git a/test/e2e/start_test.go b/test/e2e/start_test.go index 35b5cab6e..942e00123 100644 --- a/test/e2e/start_test.go +++ b/test/e2e/start_test.go @@ -40,7 +40,7 @@ var _ = Describe("Podman start", func() { }) It("podman start single container by id", func() { - session := podmanTest.Podman([]string{"create", "-d", ALPINE, "ls"}) + session := podmanTest.Podman([]string{"create", ALPINE, "ls"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) cid := session.OutputToString() @@ -50,7 +50,7 @@ var _ = Describe("Podman start", func() { }) It("podman container start single container by id", func() { - session := podmanTest.Podman([]string{"container", "create", "-d", ALPINE, "ls"}) + session := podmanTest.Podman([]string{"container", "create", ALPINE, "ls"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) cid := session.OutputToString() @@ -61,7 +61,7 @@ var _ = Describe("Podman start", func() { }) It("podman container start single container by short id", func() { - session := podmanTest.Podman([]string{"container", "create", "-d", ALPINE, "ls"}) + session := podmanTest.Podman([]string{"container", "create", ALPINE, "ls"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) cid := session.OutputToString() @@ -74,7 +74,7 @@ var _ = Describe("Podman start", func() { It("podman start single container by name", func() { name := "foobar99" - session := podmanTest.Podman([]string{"create", "-d", "--name", name, ALPINE, "ls"}) + session := podmanTest.Podman([]string{"create", "--name", name, ALPINE, "ls"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) session = podmanTest.Podman([]string{"start", name}) @@ -98,10 +98,10 @@ var _ = Describe("Podman start", func() { }) It("podman start multiple containers", func() { - session := podmanTest.Podman([]string{"create", "-d", "--name", "foobar99", ALPINE, "ls"}) + session := podmanTest.Podman([]string{"create", "--name", "foobar99", ALPINE, "ls"}) session.WaitWithDefaultTimeout() cid1 := session.OutputToString() - session2 := podmanTest.Podman([]string{"create", "-d", "--name", "foobar100", ALPINE, "ls"}) + session2 := podmanTest.Podman([]string{"create", "--name", "foobar100", ALPINE, "ls"}) session2.WaitWithDefaultTimeout() cid2 := session2.OutputToString() session = podmanTest.Podman([]string{"start", cid1, cid2}) @@ -110,7 +110,7 @@ var _ = Describe("Podman start", func() { }) It("podman start multiple containers with bogus", func() { - session := podmanTest.Podman([]string{"create", "-d", "--name", "foobar99", ALPINE, "ls"}) + session := podmanTest.Podman([]string{"create", "--name", "foobar99", ALPINE, "ls"}) session.WaitWithDefaultTimeout() cid1 := session.OutputToString() session = podmanTest.Podman([]string{"start", cid1, "doesnotexist"}) diff --git a/test/e2e/stop_test.go b/test/e2e/stop_test.go index 1437fd066..c25709a63 100644 --- a/test/e2e/stop_test.go +++ b/test/e2e/stop_test.go @@ -242,7 +242,7 @@ var _ = Describe("Podman stop", func() { defer os.RemoveAll(tmpDir) - session := podmanTest.Podman([]string{"create", "--cidfile", tmpFile, "-d", ALPINE, "top"}) + session := podmanTest.Podman([]string{"create", "--cidfile", tmpFile, ALPINE, "top"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) cid := session.OutputToStringArray()[0] diff --git a/test/e2e/systemd_test.go b/test/e2e/systemd_test.go index 9e717a0eb..218c250cd 100644 --- a/test/e2e/systemd_test.go +++ b/test/e2e/systemd_test.go @@ -59,7 +59,7 @@ WantedBy=multi-user.target Expect(stop.ExitCode()).To(Equal(0)) }() - create := podmanTest.Podman([]string{"create", "-d", "--name", "redis", "redis"}) + create := podmanTest.Podman([]string{"create", "--name", "redis", "redis"}) create.WaitWithDefaultTimeout() Expect(create.ExitCode()).To(Equal(0)) diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats index 9bd3e15a1..ac3ae2f98 100644 --- a/test/system/250-systemd.bats +++ b/test/system/250-systemd.bats @@ -42,7 +42,7 @@ function teardown() { cname=$(random_string) # See #7407 for --pull=always. - run_podman create --pull=always --name $cname --label "io.containers.autoupdate=image" --detach $IMAGE top + run_podman create --pull=always --name $cname --label "io.containers.autoupdate=image" $IMAGE top run_podman generate systemd --new $cname echo "$output" > "$UNIT_FILE" -- cgit v1.2.3-54-g00ecf