mirror of
https://github.com/containers/podman-compose.git
synced 2025-04-10 01:49:09 +02:00
Fix CMD healthchecks running with /bin/sh
Signed-off-by: Ben Krieger <ben.krieger@intel.com>
This commit is contained in:
parent
84f1fbd622
commit
0bc92fd787
@ -28,14 +28,8 @@ import sys
|
|||||||
from asyncio import Task
|
from asyncio import Task
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
try:
|
|
||||||
from shlex import quote as cmd_quote
|
|
||||||
except ImportError:
|
|
||||||
from pipes import quote as cmd_quote # pylint: disable=deprecated-module
|
|
||||||
|
|
||||||
# import fnmatch
|
# import fnmatch
|
||||||
# fnmatch.fnmatchcase(env, "*_HOST")
|
# fnmatch.fnmatchcase(env, "*_HOST")
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
from dotenv import dotenv_values
|
from dotenv import dotenv_values
|
||||||
|
|
||||||
@ -1193,7 +1187,7 @@ async def container_to_args(compose, cnt, detached=True):
|
|||||||
# podman does not add shell to handle command with whitespace
|
# podman does not add shell to handle command with whitespace
|
||||||
podman_args.extend([
|
podman_args.extend([
|
||||||
"--healthcheck-command",
|
"--healthcheck-command",
|
||||||
"/bin/sh -c " + cmd_quote(healthcheck_test),
|
json.dumps(["CMD-SHELL", healthcheck_test]),
|
||||||
])
|
])
|
||||||
elif is_list(healthcheck_test):
|
elif is_list(healthcheck_test):
|
||||||
healthcheck_test = healthcheck_test.copy()
|
healthcheck_test = healthcheck_test.copy()
|
||||||
@ -1202,13 +1196,11 @@ async def container_to_args(compose, cnt, detached=True):
|
|||||||
if healthcheck_type == "NONE":
|
if healthcheck_type == "NONE":
|
||||||
podman_args.append("--no-healthcheck")
|
podman_args.append("--no-healthcheck")
|
||||||
elif healthcheck_type == "CMD":
|
elif healthcheck_type == "CMD":
|
||||||
cmd_q = "' '".join([cmd_quote(i) for i in healthcheck_test])
|
podman_args.extend(["--healthcheck-command", json.dumps(healthcheck_test)])
|
||||||
podman_args.extend(["--healthcheck-command", "/bin/sh -c " + cmd_q])
|
|
||||||
elif healthcheck_type == "CMD-SHELL":
|
elif healthcheck_type == "CMD-SHELL":
|
||||||
if len(healthcheck_test) != 1:
|
if len(healthcheck_test) != 1:
|
||||||
raise ValueError("'CMD_SHELL' takes a single string after it")
|
raise ValueError("'CMD_SHELL' takes a single string after it")
|
||||||
cmd_q = cmd_quote(healthcheck_test[0])
|
podman_args.extend(["--healthcheck-command", json.dumps(healthcheck_test)])
|
||||||
podman_args.extend(["--healthcheck-command", "/bin/sh -c " + cmd_q])
|
|
||||||
else:
|
else:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"unknown healthcheck test type [{healthcheck_type}],\
|
f"unknown healthcheck test type [{healthcheck_type}],\
|
||||||
|
Loading…
Reference in New Issue
Block a user