healthcheck test silently ignored when of wrong type
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
Bug, affected versions:
- docker-py: 4.1.0
- docker-ce: 19.03.8
Summary
healtcheck['test'] is implicitly expected to be a str, and the API not only does not complain if it is a list, but just seemingly ignores it without any effect. The documentation is not very generous, it only mentions healthcheck has to be a dict.
How to reproduce:
from docker import from_env
containers = from_env().containers
args = ['alpine', ['sh']]
kwargs = {'tty': True, 'detach': True, 'healthcheck': {'test': 'true'}}
good = containers.run(*args, **kwargs)
assert 'Health' not in good.attrs['State']
good.reload()
assert 'Health' in good.attrs['State']
kwargs['healthcheck']['test'] = ['true']
bad = containers.run(*args, **kwargs)
assert 'Health' not in bad.attrs['State']
bad.reload()
assert 'Health' in bad.attrs['State']
Proposed fix
- assert
healthcheck['test']type is a str - document healthcheck keys
When encountering this behavior I was still under the (wrong) impression that dockerfile HEALTHCHECK can be also defined as a list, just like CMD. So you might not consider this a bug and that's fine. If you do however, I will request a pull once I get some free time.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the containers.run reproduction in the issue, comparing string and list values for healthcheck['test']. Trace how the healthcheck argument is handled, then verify that an invalid list is rejected and that the documented healthcheck keys describe the accepted input.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100