mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-16 11:58:43 +00:00
Fix healthcheck idempotency issue with strict comparison. (#88)
This commit is contained in:
parent
5fd13c79b6
commit
f5d68755c4
2
changelogs/fragments/88-docker_container-healthcheck.yml
Normal file
2
changelogs/fragments/88-docker_container-healthcheck.yml
Normal file
@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- "docker_container - fix healthcheck disabling idempotency issue with strict comparison (https://github.com/ansible-collections/community.docker/issues/85)."
|
||||
@ -2329,6 +2329,12 @@ class Container(DockerBaseClass):
|
||||
match = self._compare(getattr(self.parameters, key), value, compare)
|
||||
|
||||
if not match:
|
||||
if key == 'expected_healthcheck' and config_mapping['disable_healthcheck'] and self.parameters.disable_healthcheck:
|
||||
# If the healthcheck is disabled (both in parameters and for the current container), and the user
|
||||
# requested strict comparison for healthcheck, the comparison will fail. That's why we ignore the
|
||||
# expected_healthcheck comparison in this case.
|
||||
continue
|
||||
|
||||
# no match. record the differences
|
||||
p = getattr(self.parameters, key)
|
||||
c = value
|
||||
|
||||
@ -1699,6 +1699,21 @@
|
||||
register: healthcheck_6
|
||||
ignore_errors: yes
|
||||
|
||||
- name: healthcheck (disabled, idempotency, strict)
|
||||
docker_container:
|
||||
image: "{{ docker_test_image_alpine }}"
|
||||
command: '/bin/sh -c "sleep 10m"'
|
||||
name: "{{ cname }}"
|
||||
state: started
|
||||
healthcheck:
|
||||
test:
|
||||
- NONE
|
||||
force_kill: yes
|
||||
comparisons:
|
||||
'*': strict
|
||||
register: healthcheck_7
|
||||
ignore_errors: yes
|
||||
|
||||
- name: healthcheck (string in healthcheck test, changed)
|
||||
docker_container:
|
||||
image: "{{ docker_test_image_alpine }}"
|
||||
@ -1708,7 +1723,7 @@
|
||||
healthcheck:
|
||||
test: "sleep 1"
|
||||
force_kill: yes
|
||||
register: healthcheck_7
|
||||
register: healthcheck_8
|
||||
ignore_errors: yes
|
||||
|
||||
- name: healthcheck (string in healthcheck test, idempotency)
|
||||
@ -1720,7 +1735,7 @@
|
||||
healthcheck:
|
||||
test: "sleep 1"
|
||||
force_kill: yes
|
||||
register: healthcheck_8
|
||||
register: healthcheck_9
|
||||
ignore_errors: yes
|
||||
|
||||
- name: cleanup
|
||||
@ -1738,8 +1753,9 @@
|
||||
- healthcheck_4 is not changed
|
||||
- healthcheck_5 is changed
|
||||
- healthcheck_6 is not changed
|
||||
- healthcheck_7 is changed
|
||||
- healthcheck_8 is not changed
|
||||
- healthcheck_7 is not changed
|
||||
- healthcheck_8 is changed
|
||||
- healthcheck_9 is not changed
|
||||
when: docker_py_version is version('2.0.0', '>=')
|
||||
- assert:
|
||||
that:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user