mirror of
https://github.com/containers/podman-compose.git
synced 2025-05-05 23:04:53 +02:00
Check whether pod exists before trying to create one
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
This commit is contained in:
parent
0ea4cbe091
commit
24038dace3
1
newsfragments/check-if-pod-exists.bugfix
Normal file
1
newsfragments/check-if-pod-exists.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fixed a bug that caused attempts to create already existing pods multiple times.
|
@ -2422,8 +2422,16 @@ async def compose_build(compose, args):
|
|||||||
return status
|
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
|
async def create_pods(compose, args): # pylint: disable=unused-argument
|
||||||
for pod in compose.pods:
|
for pod in compose.pods:
|
||||||
|
if await pod_exists(compose, pod["name"]):
|
||||||
|
continue
|
||||||
|
|
||||||
podman_args = [
|
podman_args = [
|
||||||
"create",
|
"create",
|
||||||
"--name=" + pod["name"],
|
"--name=" + pod["name"],
|
||||||
|
Loading…
Reference in New Issue
Block a user