-
Notifications
You must be signed in to change notification settings - Fork 544
Description
Describe the bug
The depends_on: attribute with value "service_completed_successfully" isn't always honored, and containers may start out of their desired order.
To Reproduce
Use this compose file:
---
services:
init:
container_name: init
image: busybox
command: sh -c "echo 'Init started' && sleep 10 && echo 'Init complete'"
app:
container_name: app
image: busybox
command: sh -c "echo 'App started' && echo 'App complete'"
depends_on:
init:
condition: service_completed_successfully
Run podman-compose up 5-6 times.
Expected behavior
The init container will complete and print all of its text before app starts.
Actual behavior
Intermittently, the app container will start just after the init container starts and finish before init finishes.
Output
Undesired behavior:
$ podman-compose up
4d780508231db7903bfab54e90a1cbe0924d39aa9fcb174a8df35eff51bd572b
ec25a6b589bebd281076cf029ed0ce6ef764a9e4fbb2e976b33cf67afa932365
e2c5d07059a2b3eb52fe6ca6482269c57b8f152c14cbcdd045a39f5f8310b954
[init] | Init started
[app] | App started
[app] | App complete
[init] | Init complete
Desired behavior:
$ podman-compose up
468b853baa118eaa05468e3521d62f4f92170c9c520fe3ae01d5e5eef808d28b
5f57810587c918410f453c4835c6179108370149ff028d42d9c87ea4d632976b
e8148764fb3d0c2a1fbc5a2b8d23b084d2aac94bb9480ed5c231cacec47b5cee
[init] | Init started
[init] | Init complete
[app] | App started
[app] | App complete
Environment:
- OS: Linux 6.16.8-200.fc42.x86_64 GNU/Linux
- podman-compose version 1.5.0
- podman version 5.6.2
Additional context
This behavior can be reproduced using podman alone. If podman wait is run immediately after podman start then it might not be enough time for the container to have actually started (i.e. "stopped" is the initial state of a container). A delay of only 0.01 seconds (i.e. sleep 0.01) is usually enough to overcome this race condition.
I'll also probably file a bug in Podman itself. Seems reasonable that a created container might have a different status (e.g. "created") compared to another container that actually ran and exited successfully.