diff --git a/plugins/module_utils/module_container/base.py b/plugins/module_utils/module_container/base.py index 0f776aa5c..cdecbb928 100644 --- a/plugins/module_utils/module_container/base.py +++ b/plugins/module_utils/module_container/base.py @@ -938,6 +938,7 @@ def _compare_platform(option, param_value, container_value): interval=dict(type='str'), timeout=dict(type='str'), start_period=dict(type='str'), + start_interval=dict(type='str'), retries=dict(type='int'), )) ) diff --git a/plugins/module_utils/module_container/docker_api.py b/plugins/module_utils/module_container/docker_api.py index 61a5500c9..82504688c 100644 --- a/plugins/module_utils/module_container/docker_api.py +++ b/plugins/module_utils/module_container/docker_api.py @@ -751,6 +751,7 @@ def _preprocess_healthcheck(module, client, api_version, value): 'Interval': value.get('interval'), 'Timeout': value.get('timeout'), 'StartPeriod': value.get('start_period'), + 'StartInterval': value.get('start_interval'), 'Retries': value.get('retries'), }) diff --git a/plugins/module_utils/util.py b/plugins/module_utils/util.py index efd3301f1..cad6408d0 100644 --- a/plugins/module_utils/util.py +++ b/plugins/module_utils/util.py @@ -348,9 +348,9 @@ def normalize_healthcheck(healthcheck, normalize_test=False): result = dict() # All supported healthcheck parameters - options = ('test', 'interval', 'timeout', 'start_period', 'retries') + options = ('test', 'interval', 'timeout', 'start_period', 'start_interval', 'retries') - duration_options = ('interval', 'timeout', 'start_period') + duration_options = ('interval', 'timeout', 'start_period', 'start_interval') for key in options: if key in healthcheck: diff --git a/plugins/modules/docker_container.py b/plugins/modules/docker_container.py index d7dbc3780..cb587bbce 100644 --- a/plugins/modules/docker_container.py +++ b/plugins/modules/docker_container.py @@ -369,7 +369,7 @@ - Configure a check that is run to determine whether or not containers for this service are "healthy". - "See the docs for the L(HEALTHCHECK Dockerfile instruction,https://docs.docker.com/engine/reference/builder/#healthcheck) for details on how healthchecks work." - - "O(healthcheck.interval), O(healthcheck.timeout) and O(healthcheck.start_period) are specified as durations. + - "O(healthcheck.interval), O(healthcheck.timeout) O(healthcheck.start_period) and O(healthcheck.start_interval) are specified as durations. They accept duration as a string in a format that look like: V(5h34m56s), V(1m30s), and so on. The supported units are V(us), V(ms), V(s), V(m) and V(h)." type: dict @@ -399,6 +399,11 @@ - Start period for the container to initialize before starting health-retries countdown. - The default used by the Docker daemon is V(0s). type: str + start_interval: + description: + - Time between health checks during the start period. This option requires Docker Engine version 25.0 or later. + - The default used by the Docker daemon is V(5s). + type: str hostname: description: - The container's hostname. @@ -1196,6 +1201,7 @@ timeout: 10s retries: 3 start_period: 30s + start_interval: 10s - name: Remove healthcheck from container community.docker.docker_container: diff --git a/plugins/modules/docker_swarm_service.py b/plugins/modules/docker_swarm_service.py index 4660d1138..6b20e846d 100644 --- a/plugins/modules/docker_swarm_service.py +++ b/plugins/modules/docker_swarm_service.py @@ -148,7 +148,7 @@ - Configure a check that is run to determine whether or not containers for this service are "healthy". See the docs for the L(HEALTHCHECK Dockerfile instruction,https://docs.docker.com/engine/reference/builder/#healthcheck) for details on how healthchecks work. - - "O(healthcheck.interval), O(healthcheck.timeout), and O(healthcheck.start_period) are specified as durations. + - "O(healthcheck.interval), O(healthcheck.timeout), O(healthcheck.start_period) and O(healthcheck.start_interval) are specified as durations. They accept duration as a string in a format that look like: V(5h34m56s), V(1m30s), and so on. The supported units are V(us), V(ms), V(s), V(m) and V(h)." type: dict @@ -174,6 +174,10 @@ description: - Start period for the container to initialize before starting health-retries countdown. type: str + start_interval: + description: + - Time between health checks during the start period. This option requires Docker Engine version 25.0 or later. + type: str hostname: description: - Container hostname. @@ -701,6 +705,7 @@ "interval": 90000000000, "retries": 3, "start_period": 30000000000, + "start_interval": 10000000000, "test": [ "CMD", "curl", @@ -920,6 +925,7 @@ timeout: 10s retries: 3 start_period: 30s + start_interval: 10s - name: Configure service resources community.docker.docker_swarm_service: @@ -2185,6 +2191,7 @@ def get_service(self, name): 'Interval': 'interval', 'Timeout': 'timeout', 'StartPeriod': 'start_period', + 'StartInterval': 'start_interval', 'Retries': 'retries' } healthcheck = dict( @@ -2585,6 +2592,12 @@ def _detect_healthcheck_start_period(client): return False +def _detect_healthcheck_start_interval(client): + if client.module.params['healthcheck']: + return client.module.params['healthcheck']['start_interval'] is not None + return False + + def _detect_mount_tmpfs_usage(client): for mount in client.module.params['mounts'] or []: if mount.get('type') == 'tmpfs': @@ -2684,6 +2697,7 @@ def main(): interval=dict(type='str'), timeout=dict(type='str'), start_period=dict(type='str'), + start_interval=dict(type='str'), retries=dict(type='int'), )), hostname=dict(type='str'), @@ -2779,6 +2793,12 @@ def main(): detect_usage=_detect_healthcheck_start_period, usage_msg='set healthcheck.start_period' ), + healthcheck_start_interval=dict( + docker_py_version='2.6.0', + docker_api_version='1.29', + detect_usage=_detect_healthcheck_start_interval, + usage_msg='set healthcheck.start_interval' + ), update_config_max_failure_ratio=dict( docker_py_version='2.1.0', detect_usage=lambda c: (c.module.params['update_config'] or {}).get(