-
Notifications
You must be signed in to change notification settings - Fork 489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: proper healthchecks support #23
Comments
Sorry for my bad Pythonese. Your solution using I tested your latest change and it doesn't handle all cases correctly. Please see the latest commit I pushed to my fork. Do you want a PR for it or can you cherry-pick it? |
if my comments in the code should be like if is_str(healthcheck_test):
# podman does not add shell to handle command with whitespace
args.extend(['--healthcheck-command', healthcheck_test])
elif is_list(healthcheck_test):
# If it’s a list, first item is either NONE, CMD or CMD-SHELL.
healthcheck_type = healthcheck_test.pop(0)
if healthcheck_type == 'NONE':
args.append("--no-healthcheck")
elif healthcheck_type == 'CMD':
args.extend(['--healthcheck-command', json.dumps(healthcheck_test)])
elif healthcheck_type == 'CMD-SHELL':
if len(healthcheck_test)!=1:
raise ValueError("'CMD_SHELL' takes a single string after it")
args.extend(['--healthcheck-command', healthcheck_test]) |
Don't know if that error has anything with this:
on current master (e21932e) |
@chpio I noticed that too and fixed it in my patch stefanb2/podman-compose@d1583d5b |
@chpio I've fixed the typo, please tell me if it fixed the issue @stefanb2 I did not like quoting the whole thing as you did
because when we pass arrays anyway, I'm following it's not compose job to work with shell, compose does not even know which shell to use (bash, sh, or zsh), if I want to inspect the image to know the shell, I might need to pull it first, but I can't pull it every time if it's already pulled. (it's a lot of job to do in compose) on the other hand, podman knows. |
@muayyad-alsadi oops I just looked at the generated command lines and missed the fact that your are not passing them to the shell. Just forget my change then. |
yeah, thank you for that |
I am seeing an error here:
The health check in my compose file:
I was able to get around this by using |
Healthcheck not working on podman-compose (not tested on docker) if /bin/sh not available in container even when using CMD in heathcheck.test (reproduction).
services:
test:
build:
context: .
container_name: healthcheck_test
healthcheck:
test: [
"CMD",
"/healthcheck",
"http://localhost:8080/ping"
]
interval: 5s
timeout: 5s
retries: 5 podman inspect --format "{{json .State.Health }}" healthcheck_test | jq
{
"Status": "unhealthy",
"FailingStreak": 18,
"Log": [
{
"Start": "2024-02-15T10:34:44.046709663+03:00",
"End": "2024-02-15T10:34:44.131872722+03:00",
"ExitCode": 1,
"Output": ""
}, |
Is this still in progress? |
Edit: no, my previous comment was wrong. |
continue on #22
https://docs.docker.com/compose/compose-file/#healthcheck
https://docs.docker.com/engine/reference/builder/#healthcheck
https://docs.docker.com/engine/reference/run/#healthcheck
and
containers/podman#3507
The text was updated successfully, but these errors were encountered: