Skip to content
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

Show why healthcheck_cmd is failing #129

Open
letmerecall opened this issue Feb 14, 2022 · 5 comments
Open

Show why healthcheck_cmd is failing #129

letmerecall opened this issue Feb 14, 2022 · 5 comments

Comments

@letmerecall
Copy link

letmerecall commented Feb 14, 2022

Description

Is there any way to show the output of the healthcheck_cmd ? Like why it's failing?
If not, it'd be great if we can have something like that.

Why it's important?

I want to perform an integration test on a container which take around 2 minutes to warm up. In case I have some issue with the healthcheck (hence the container) all I am left with is this cryptic message with not much information to actually debug the issue.

(monty) ➜  tox
no-env-8080 installed: attrs==21.4.0,certifi==2021.10.8,charset-normalizer==2.0.12,idna==3.3,iniconfig==1.1.1,packaging==21.3,pluggy==1.0.0,py==1.11.0,pyparsing==3.0.7,pytest==7.0.1,pytest-dotenv==0.5.2,python-dotenv==0.19.2,requests==2.27.1,tomli==2.0.1,urllib3==1.26.8
no-env-8080 docker: run 'holy-grail:pytest' (from 'holy-grail')
no-env-8080 docker: health check 'holy-grail:pytest' (from 'holy-grail')
no-env-8080 docker: remove '26bb537d52' (from 'holy-grail)
______________________________________________________________________________ summary ______________________________________________________________________________
ERROR:   no-env-8080: 'holy-grail:pytest' (from 'holy-grail') failed health check
Traceback (most recent call last):
  File "/Users/girish/miniconda3/envs/monty/bin/tox", line 8, in <module>
    sys.exit(cmdline())
  File "/Users/girish/miniconda3/envs/monty/lib/python3.8/site-packages/tox/session/__init__.py", line 44, in cmdline
    main(args)
  File "/Users/girish/miniconda3/envs/monty/lib/python3.8/site-packages/tox/session/__init__.py", line 69, in main
    exit_code = session.runcommand()
  File "/Users/girish/miniconda3/envs/monty/lib/python3.8/site-packages/tox/session/__init__.py", line 197, in runcommand
    return self.subcommand_test()
  File "/Users/girish/miniconda3/envs/monty/lib/python3.8/site-packages/tox/session/__init__.py", line 225, in subcommand_test
    run_sequential(self.config, self.venv_dict)
  File "/Users/girish/miniconda3/envs/monty/lib/python3.8/site-packages/tox/session/commands/run/sequential.py", line 22, in run_sequential
    runtestenv(venv, config)
  File "/Users/girish/miniconda3/envs/monty/lib/python3.8/site-packages/tox/session/commands/run/sequential.py", line 73, in runtestenv
    config.pluginmanager.hook.tox_runtest_pre(venv=venv)
  File "/Users/girish/miniconda3/envs/monty/lib/python3.8/site-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  File "/Users/girish/miniconda3/envs/monty/lib/python3.8/site-packages/pluggy/_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/Users/girish/miniconda3/envs/monty/lib/python3.8/site-packages/pluggy/_callers.py", line 60, in _multicall
    return outcome.get_result()
  File "/Users/girish/miniconda3/envs/monty/lib/python3.8/site-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/Users/girish/miniconda3/envs/monty/lib/python3.8/site-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
  File "/Users/girish/miniconda3/envs/monty/lib/python3.8/site-packages/tox_docker/__init__.py", line 338, in tox_runtest_pre
    raise HealthCheckFailed(msg)
tox_docker.HealthCheckFailed: 'holy-grail:pytest' (from 'holy-grail') failed health check
@letmerecall letmerecall changed the title Show healthcheck command result in output Show why healthcheck_cmd command is failing Feb 14, 2022
@letmerecall letmerecall changed the title Show why healthcheck_cmd command is failing Show why healthcheck_cmd is failing Feb 14, 2022
@terrynguyen255
Copy link

Please make this happen. I'm so frustrated to blindly fixing my tox don't know why a container fails its healthcheck

@notzippy
Copy link

Im pretty sure the healthcheck results are stored in the docker logs, so when the healthcheck fails ask the container for the logs and output that as an error log.

@terrynguyen255
Copy link

Hi @notzippy ,

Thank you for the response.
Unfortunately, I think your answer does not work. Because after a docker container failed, all the containers will be removed. Therefore, you cannot access there log
image

@notzippy
Copy link

@Nogias9x At the point in code that I referenced, the containers are still running and have not been removed. If I have time Ill submit a PR to demonstrate

@tkdchen
Copy link

tkdchen commented Jun 8, 2024

As of 5.0.0, once the status is unhealthy, tox-docker removes the containers by default.

The output messages .[].State.Health.Log[].Output should be gathered and reported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants