Skip to content

Commit

Permalink
Use new Podman flags for healthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
recursiveribbons committed Sep 23, 2023
1 parent bce40c2 commit cba6a70
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions podman_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ def container_to_args(compose, cnt, detached=True):
if is_str(healthcheck_test):
# podman does not add shell to handle command with whitespace
podman_args.extend(
["--healthcheck-command", "/bin/sh -c " + cmd_quote(healthcheck_test)]
["--health-cmd", "/bin/sh -c " + cmd_quote(healthcheck_test)]
)
elif is_list(healthcheck_test):
healthcheck_test = healthcheck_test.copy()
Expand All @@ -1050,12 +1050,12 @@ def container_to_args(compose, cnt, detached=True):
podman_args.append("--no-healthcheck")
elif healthcheck_type == "CMD":
cmd_q = "' '".join([cmd_quote(i) for i in healthcheck_test])
podman_args.extend(["--healthcheck-command", "/bin/sh -c " + cmd_q])
podman_args.extend(["--health-cmd", "/bin/sh -c " + cmd_q])
elif healthcheck_type == "CMD-SHELL":
if len(healthcheck_test) != 1:
raise ValueError("'CMD_SHELL' takes a single string after it")
cmd_q = cmd_quote(healthcheck_test[0])
podman_args.extend(["--healthcheck-command", "/bin/sh -c " + cmd_q])
podman_args.extend(["--health-cmd", "/bin/sh -c " + cmd_q])
else:
raise ValueError(
f"unknown healthcheck test type [{healthcheck_type}],\
Expand All @@ -1066,15 +1066,15 @@ def container_to_args(compose, cnt, detached=True):

# interval, timeout and start_period are specified as durations.
if "interval" in healthcheck:
podman_args.extend(["--healthcheck-interval", healthcheck["interval"]])
podman_args.extend(["--health-interval", healthcheck["interval"]])
if "timeout" in healthcheck:
podman_args.extend(["--healthcheck-timeout", healthcheck["timeout"]])
podman_args.extend(["--health-timeout", healthcheck["timeout"]])
if "start_period" in healthcheck:
podman_args.extend(["--healthcheck-start-period", healthcheck["start_period"]])
podman_args.extend(["--health-start-period", healthcheck["start_period"]])

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

# handle podman extension
x_podman = cnt.get("x-podman", None)
Expand Down

0 comments on commit cba6a70

Please sign in to comment.