Skip to content

Commit

Permalink
Merge pull request #987 from p12tic/check-if-pod-exists-before-creating
Browse files Browse the repository at this point in the history
Check whether pod exists before trying to create one
  • Loading branch information
p12tic committed Jul 3, 2024
2 parents 0ea4cbe + 24038da commit 0517b9e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions newsfragments/check-if-pod-exists.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a bug that caused attempts to create already existing pods multiple times.
8 changes: 8 additions & 0 deletions podman_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down

0 comments on commit 0517b9e

Please sign in to comment.