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>
pull/66162/head
Hannes Ljungberg 5 years ago committed by ansibot
parent f7d4121446
commit f31b8e08b2

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

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

@ -909,6 +909,7 @@
timeout: 2s timeout: 2s
interval: 0h0m2s3ms4us interval: 0h0m2s3ms4us
retries: 2 retries: 2
start_period: 20s
register: healthcheck_1 register: healthcheck_1
ignore_errors: yes ignore_errors: yes
@ -926,6 +927,7 @@
timeout: 2s timeout: 2s
interval: 0h0m2s3ms4us interval: 0h0m2s3ms4us
retries: 2 retries: 2
start_period: 20s
register: healthcheck_2 register: healthcheck_2
ignore_errors: yes ignore_errors: yes
@ -1029,12 +1031,12 @@
- healthcheck_7 is not changed - healthcheck_7 is not changed
- healthcheck_8 is changed - healthcheck_8 is changed
- healthcheck_9 is not 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: - assert:
that: that:
- healthcheck_1 is failed - healthcheck_1 is failed
- "'Minimum version required' in healthcheck_1.msg" - "'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 ####################################################### ## hostname #######################################################

Loading…
Cancel
Save