docker_swarm_service: Fix parsing of Healthcheck.StartPeriod (#66151)

* Parse Healthcheck.StartPeriod properly

* Add changelog fragment

* Use proper markup in changelog

Co-Authored-By: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Hannes Ljungberg 2020-01-02 15:23:36 +01:00 committed by ansibot
parent f7d4121446
commit f31b8e08b2
3 changed files with 17 additions and 7 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- "docker_swarm_service - fix task always reporting as changed when using ``healthcheck.start_period``."

View file

@ -2270,10 +2270,16 @@ class DockerServiceManager(object):
healthcheck_data = task_template_data['ContainerSpec'].get('Healthcheck')
if healthcheck_data:
options = ['test', 'interval', 'timeout', 'start_period', 'retries']
options = {
'Test': 'test',
'Interval': 'interval',
'Timeout': 'timeout',
'StartPeriod': 'start_period',
'Retries': 'retries'
}
healthcheck = dict(
(key.lower(), value) for key, value in healthcheck_data.items()
if value is not None and key.lower() in options
(options[key], value) for key, value in healthcheck_data.items()
if value is not None and key in options
)
ds.healthcheck = healthcheck
@ -2882,8 +2888,8 @@ def main():
usage_msg='set publish.mode'
),
healthcheck_start_period=dict(
docker_py_version='2.4.0',
docker_api_version='1.25',
docker_py_version='2.6.0',
docker_api_version='1.29',
detect_usage=_detect_healthcheck_start_period,
usage_msg='set healthcheck.start_period'
),

View file

@ -909,6 +909,7 @@
timeout: 2s
interval: 0h0m2s3ms4us
retries: 2
start_period: 20s
register: healthcheck_1
ignore_errors: yes
@ -926,6 +927,7 @@
timeout: 2s
interval: 0h0m2s3ms4us
retries: 2
start_period: 20s
register: healthcheck_2
ignore_errors: yes
@ -1029,12 +1031,12 @@
- healthcheck_7 is not changed
- healthcheck_8 is changed
- healthcheck_9 is not changed
when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.6.0', '>=')
when: docker_api_version is version('1.29', '>=') and docker_py_version is version('2.6.0', '>=')
- assert:
that:
- healthcheck_1 is failed
- "'Minimum version required' in healthcheck_1.msg"
when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.6.0', '<')
when: docker_api_version is version('1.29', '<') or docker_py_version is version('2.6.0', '<')
###################################################################
## hostname #######################################################