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/start_interval_unsupported.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Stop translating Compose `healthcheck.start_interval` to the unrelated Podman `--health-startup-interval` flag (which belongs to a separate startup-healthcheck mechanism). The field is now reported as unsupported with a warning until Podman gains a native equivalent (containers/podman#26505). Fixes #1500.
19 changes: 17 additions & 2 deletions podman_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -1574,15 +1574,30 @@ async def container_to_args(
else:
raise ValueError("'healthcheck.test' either a string or a list")

# interval, timeout, start_period, and start_interval are specified as durations.
# interval, timeout, and start_period are specified as durations.
if "interval" in healthcheck:
podman_args.extend(["--health-interval", healthcheck["interval"]])
if "timeout" in healthcheck:
podman_args.extend(["--health-timeout", healthcheck["timeout"]])
if "start_period" in healthcheck:
podman_args.extend(["--health-start-period", healthcheck["start_period"]])
if "start_interval" in healthcheck:
podman_args.extend(["--health-startup-interval", healthcheck["start_interval"]])
# The previous mapping translated start_interval to
# --health-startup-interval, but that Podman flag belongs to a
# separate startup-healthcheck mechanism gated by --health-startup-cmd
# (which podman-compose does not generate), so the Compose-spec
# semantics of start_interval were silently lost. Podman does not yet
# provide a direct equivalent (see containers/podman#26505), so warn
# the user and drop the broken mapping. Re-enable once the Podman
# native equivalent lands.
log.warning(
"Compose 'healthcheck.start_interval' is currently not supported "
"by podman-compose: Podman has no equivalent for the "
"startup-period interval yet (see containers/podman#26505); the "
"field %r is being ignored for service %r.",
healthcheck["start_interval"],
cnt.get("name", cnt.get("service_name", "?")),
)

# convert other parameters to string
if "retries" in healthcheck:
Expand Down
28 changes: 25 additions & 3 deletions tests/unit/test_container_to_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,6 @@ async def test_healthcheck_options(self) -> None:
"timeout": "10s",
"retries": "3",
"start_period": "5s",
"start_interval": "6s",
}

args = await container_to_args(c, cnt)
Expand All @@ -1207,14 +1206,37 @@ async def test_healthcheck_options(self) -> None:
'10s',
'--health-start-period',
'5s',
'--health-startup-interval',
'6s',
'--health-retries',
'3',
"busybox",
],
)

async def test_healthcheck_start_interval_warns_and_omits_podman_flag(self) -> None:
"""``start_interval`` has no Podman equivalent yet (containers/podman#26505).

The old behaviour silently mapped it to ``--health-startup-interval``,
but that flag belongs to a different mechanism gated by
``--health-startup-cmd`` (which podman-compose never emits), so the
Compose-spec semantics were lost. The current contract is: emit a
warning, do not pass any ``--health-startup-interval`` flag.
"""
c = create_compose_mock()
cnt = get_minimal_container()
cnt["healthcheck"] = {
"test": ["CMD", "true"],
"start_interval": "1s",
}

with self.assertLogs("podman_compose", level="WARNING") as cm:
args = await container_to_args(c, cnt)

self.assertTrue(
any("start_interval" in msg for msg in cm.output),
f"expected a warning mentioning start_interval, got: {cm.output!r}",
)
self.assertNotIn("--health-startup-interval", args)

@parameterized.expand([
"",
"container:ipc_test0_container",
Expand Down