From fe488b5f11836a021bcef6217aeeea41b1321217 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Mon, 15 Jun 2020 13:49:36 +0200 Subject: pod create --replace Add a `--replace` flag to the `pod create` command. If another pod with the same name already exists, it will be replaced and removed. Adding this flag is motivated by #5485 to make running Podman in systemd units (or any other scripts/automation) more robust. In case of a crash, a pod may not be removed by a sytemd unit anymore. The `--replace` flag allows for supporting crashes. Note that the `--replace` flag does not require the `--name` flag to be set, so it can be set unconditionally in `podman generate systemd`. Signed-off-by: Valentin Rothberg --- test/e2e/pod_create_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test') diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go index a7d5783cb..8d07f6290 100644 --- a/test/e2e/pod_create_test.go +++ b/test/e2e/pod_create_test.go @@ -305,4 +305,19 @@ var _ = Describe("Podman pod create", func() { data := check.InspectPodToJSON() Expect(data.ID).To(Equal(string(id))) }) + + It("podman pod create --replace", func() { + // Make sure we error out with --name. + session := podmanTest.Podman([]string{"pod", "create", "--replace", ALPINE, "/bin/sh"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(125)) + + // Create and replace 5 times in a row the "same" pod. + podName := "testCtr" + for i := 0; i < 5; i++ { + session = podmanTest.Podman([]string{"pod", "create", "--replace", "--name", podName}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + } + }) }) -- cgit v1.2.3-54-g00ecf