Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/stop_grace_period.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pass ``stop_grace_period`` as ``--stop-timeout`` to ``podman create`` so containers respect the configured grace period instead of using podman's 10-second default.
5 changes: 5 additions & 0 deletions podman_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,11 @@ async def container_to_args(
podman_args.append("-i")
if cnt.get("stop_signal"):
podman_args.extend(["--stop-signal", cnt["stop_signal"]])
stop_grace = cnt.get("stop_grace_period")
if stop_grace:
timeout = str_to_seconds(stop_grace)
if timeout is not None:
podman_args.extend(["--stop-timeout", str(timeout)])

sysctls = cnt.get("sysctls")
if sysctls is not None:
Expand Down
38 changes: 38 additions & 0 deletions tests/unit/test_container_to_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,3 +1279,41 @@ async def test_ipc_invalid_service_name(self) -> None:
ValueError, r"invalid ipc mode \[service:invalid\], service \[invalid\] does not exist"
):
await container_to_args(c, cnt)

async def test_stop_grace_period(self) -> None:
c = create_compose_mock()

cnt = get_minimal_container()
cnt["stop_grace_period"] = "30s"

args = await container_to_args(c, cnt)
self.assertEqual(
args,
[
"--name=project_name_service_name1",
"-d",
"--network=bridge:alias=service_name",
"--stop-timeout",
"30",
"busybox",
],
)

async def test_stop_grace_period_minutes(self) -> None:
c = create_compose_mock()

cnt = get_minimal_container()
cnt["stop_grace_period"] = "1m30s"

args = await container_to_args(c, cnt)
self.assertEqual(
args,
[
"--name=project_name_service_name1",
"-d",
"--network=bridge:alias=service_name",
"--stop-timeout",
"90",
"busybox",
],
)