docker_container and docker_swarm_service: allow to actually disable healthcheck of image (#66599)
* Allow to actually disable healthcheck of image. * Add changelog.
This commit is contained in:
parent
d6f2b4e788
commit
5c1a3a3ac2
3 changed files with 14 additions and 2 deletions
3
changelogs/fragments/66599-docker-healthcheck.yml
Normal file
3
changelogs/fragments/66599-docker-healthcheck.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
bugfixes:
|
||||||
|
- "docker_container - passing ``test: [NONE]`` now actually disables the image's healthcheck, as documented."
|
||||||
|
- "docker_swarm_service - passing ``test: [NONE]`` now actually disables the image's healthcheck, as documented."
|
|
@ -1480,6 +1480,10 @@ class TaskParameters(DockerBaseClass):
|
||||||
if self.client.option_minimal_versions[value]['supported']:
|
if self.client.option_minimal_versions[value]['supported']:
|
||||||
result[key] = getattr(self, value)
|
result[key] = getattr(self, value)
|
||||||
|
|
||||||
|
if self.disable_healthcheck:
|
||||||
|
# Make sure image's health check is overridden
|
||||||
|
result['healthcheck'] = {'test': ['NONE']}
|
||||||
|
|
||||||
if self.networks_cli_compatible and self.networks:
|
if self.networks_cli_compatible and self.networks:
|
||||||
network = self.networks[0]
|
network = self.networks[0]
|
||||||
params = dict()
|
params = dict()
|
||||||
|
|
|
@ -1927,8 +1927,11 @@ class DockerService(DockerBaseClass):
|
||||||
def has_healthcheck_changed(self, old_publish):
|
def has_healthcheck_changed(self, old_publish):
|
||||||
if self.healthcheck_disabled is False and self.healthcheck is None:
|
if self.healthcheck_disabled is False and self.healthcheck is None:
|
||||||
return False
|
return False
|
||||||
if self.healthcheck_disabled and old_publish.healthcheck is None:
|
if self.healthcheck_disabled:
|
||||||
return False
|
if old_publish.healthcheck is None:
|
||||||
|
return False
|
||||||
|
if old_publish.healthcheck.get('test') == ['NONE']:
|
||||||
|
return False
|
||||||
return self.healthcheck != old_publish.healthcheck
|
return self.healthcheck != old_publish.healthcheck
|
||||||
|
|
||||||
def has_publish_changed(self, old_publish):
|
def has_publish_changed(self, old_publish):
|
||||||
|
@ -2053,6 +2056,8 @@ class DockerService(DockerBaseClass):
|
||||||
container_spec_args['labels'] = self.container_labels
|
container_spec_args['labels'] = self.container_labels
|
||||||
if self.healthcheck is not None:
|
if self.healthcheck is not None:
|
||||||
container_spec_args['healthcheck'] = types.Healthcheck(**self.healthcheck)
|
container_spec_args['healthcheck'] = types.Healthcheck(**self.healthcheck)
|
||||||
|
elif self.healthcheck_disabled:
|
||||||
|
container_spec_args['healthcheck'] = types.Healthcheck(test=['NONE'])
|
||||||
if self.hostname is not None:
|
if self.hostname is not None:
|
||||||
container_spec_args['hostname'] = self.hostname
|
container_spec_args['hostname'] = self.hostname
|
||||||
if self.hosts is not None:
|
if self.hosts is not None:
|
||||||
|
|
Loading…
Reference in a new issue