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>
(cherry picked from commit f31b8e08b2)
pull/66374/head
Hannes Ljungberg 6 years ago committed by Matt Clay
parent 0d08d78637
commit 7a55bc1902

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

@ -2106,10 +2106,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
@ -2666,8 +2672,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'
),

@ -884,6 +884,7 @@
timeout: 2s
interval: 0h0m2s3ms4us
retries: 2
start_period: 20s
register: healthcheck_1
ignore_errors: yes
@ -901,6 +902,7 @@
timeout: 2s
interval: 0h0m2s3ms4us
retries: 2
start_period: 20s
register: healthcheck_2
ignore_errors: yes
@ -1004,12 +1006,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 #######################################################

Loading…
Cancel
Save