From 24038dace3906bff91c2ffb952f3d3850478aa8c Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Wed, 3 Jul 2024 19:15:19 +0300 Subject: [PATCH] Check whether pod exists before trying to create one Signed-off-by: Povilas Kanapickas --- newsfragments/check-if-pod-exists.bugfix | 1 + podman_compose.py | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 newsfragments/check-if-pod-exists.bugfix diff --git a/newsfragments/check-if-pod-exists.bugfix b/newsfragments/check-if-pod-exists.bugfix new file mode 100644 index 0000000..8c4a472 --- /dev/null +++ b/newsfragments/check-if-pod-exists.bugfix @@ -0,0 +1 @@ +Fixed a bug that caused attempts to create already existing pods multiple times. diff --git a/podman_compose.py b/podman_compose.py index 200ce78..5c2d6bb 100755 --- a/podman_compose.py +++ b/podman_compose.py @@ -2422,8 +2422,16 @@ async def compose_build(compose, args): return status +async def pod_exists(compose, name): + exit_code = await compose.podman.run([], "pod", ["exists", name]) + return exit_code == 0 + + async def create_pods(compose, args): # pylint: disable=unused-argument for pod in compose.pods: + if await pod_exists(compose, pod["name"]): + continue + podman_args = [ "create", "--name=" + pod["name"],