Skip to content

Commit e15e96a

Browse files
recursiveribbonsmokibit
authored andcommitted
Use new Podman flags for healthcheck
Relevant Podman documentation here: https://docs.podman.io/en/v5.4.0/markdown/podman-healthcheck-run.1.html Signed-off-by: Robin Syl <robin@robinsyl.dev> Signed-off-by: Monika Kairaityte <monika@kibit.lt>
1 parent f618ff3 commit e15e96a

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add support for `start_interval` option.
2+
Rename healthcheck flags to be consistent with Podman options.

podman_compose.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,7 @@ async def container_to_args(
12861286
if isinstance(healthcheck_test, str):
12871287
# podman does not add shell to handle command with whitespace
12881288
podman_args.extend([
1289-
"--healthcheck-command",
1289+
"--health-cmd",
12901290
json.dumps(["CMD-SHELL", healthcheck_test]),
12911291
])
12921292
elif is_list(healthcheck_test):
@@ -1296,11 +1296,11 @@ async def container_to_args(
12961296
if healthcheck_type == "NONE":
12971297
podman_args.append("--no-healthcheck")
12981298
elif healthcheck_type == "CMD":
1299-
podman_args.extend(["--healthcheck-command", json.dumps(healthcheck_test)])
1299+
podman_args.extend(["--health-cmd", json.dumps(healthcheck_test)])
13001300
elif healthcheck_type == "CMD-SHELL":
13011301
if len(healthcheck_test) != 1:
13021302
raise ValueError("'CMD_SHELL' takes a single string after it")
1303-
podman_args.extend(["--healthcheck-command", json.dumps(healthcheck_test)])
1303+
podman_args.extend(["--health-cmd", json.dumps(healthcheck_test)])
13041304
else:
13051305
raise ValueError(
13061306
f"unknown healthcheck test type [{healthcheck_type}],\
@@ -1311,15 +1311,15 @@ async def container_to_args(
13111311

13121312
# interval, timeout and start_period are specified as durations.
13131313
if "interval" in healthcheck:
1314-
podman_args.extend(["--healthcheck-interval", healthcheck["interval"]])
1314+
podman_args.extend(["--health-interval", healthcheck["interval"]])
13151315
if "timeout" in healthcheck:
1316-
podman_args.extend(["--healthcheck-timeout", healthcheck["timeout"]])
1316+
podman_args.extend(["--health-timeout", healthcheck["timeout"]])
13171317
if "start_period" in healthcheck:
1318-
podman_args.extend(["--healthcheck-start-period", healthcheck["start_period"]])
1318+
podman_args.extend(["--health-start-period", healthcheck["start_period"]])
13191319

13201320
# convert other parameters to string
13211321
if "retries" in healthcheck:
1322-
podman_args.extend(["--healthcheck-retries", str(healthcheck["retries"])])
1322+
podman_args.extend(["--health-retries", str(healthcheck["retries"])])
13231323

13241324
# handle podman extension
13251325
if 'x-podman' in cnt:

tests/unit/test_container_to_args.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ async def test_healthcheck_string(self) -> None:
889889
"--name=project_name_service_name1",
890890
"-d",
891891
"--network=bridge:alias=service_name",
892-
"--healthcheck-command",
892+
"--health-cmd",
893893
'["CMD-SHELL", "cmd arg1 arg2"]',
894894
"busybox",
895895
],
@@ -909,7 +909,7 @@ async def test_healthcheck_cmd_args(self) -> None:
909909
"--name=project_name_service_name1",
910910
"-d",
911911
"--network=bridge:alias=service_name",
912-
"--healthcheck-command",
912+
"--health-cmd",
913913
'["cmd", "arg1", "arg2"]',
914914
"busybox",
915915
],
@@ -929,7 +929,7 @@ async def test_healthcheck_cmd_shell(self) -> None:
929929
"--name=project_name_service_name1",
930930
"-d",
931931
"--network=bridge:alias=service_name",
932-
"--healthcheck-command",
932+
"--health-cmd",
933933
'["cmd arg1 arg2"]',
934934
"busybox",
935935
],

0 commit comments

Comments
 (0)