diff --git a/changelogs/fragments/163-docker_compose-timeout-fix.yml b/changelogs/fragments/163-docker_compose-timeout-fix.yml new file mode 100644 index 00000000..492185d9 --- /dev/null +++ b/changelogs/fragments/163-docker_compose-timeout-fix.yml @@ -0,0 +1,4 @@ +--- +breaking_changes: + - docker_compose - fixed ``timeout`` defaulting behavior so that ``stop_grace_period``, if defined in the compose + file, will be used if `timeout`` is not specified (https://github.com/ansible-collections/community.docker/pull/163). diff --git a/plugins/modules/docker_compose.py b/plugins/modules/docker_compose.py index 8b42e887..b3cc12f4 100644 --- a/plugins/modules/docker_compose.py +++ b/plugins/modules/docker_compose.py @@ -163,8 +163,10 @@ options: timeout: description: - Timeout in seconds for container shutdown when attached or when containers are already running. + - By default C(compose) will use a C(10s) timeout unless C(default_grace_period) is defined for a + particular service in the I(project_src). type: int - default: 10 + default: null use_ssh_client: description: - Currently ignored for this module, but might suddenly be supported later on. @@ -495,14 +497,13 @@ try: from compose.cli.command import project_from_options from compose.service import NoSuchImageError from compose.cli.main import convergence_strategy_from_opts, build_action_from_opts, image_type_from_opt - from compose.const import DEFAULT_TIMEOUT, LABEL_SERVICE, LABEL_PROJECT, LABEL_ONE_OFF + from compose.const import LABEL_SERVICE, LABEL_PROJECT, LABEL_ONE_OFF HAS_COMPOSE = True HAS_COMPOSE_EXC = None MINIMUM_COMPOSE_VERSION = '1.7.0' except ImportError as dummy: HAS_COMPOSE = False HAS_COMPOSE_EXC = traceback.format_exc() - DEFAULT_TIMEOUT = 10 from ansible.module_utils.common.text.converters import to_native @@ -1177,7 +1178,7 @@ def main(): pull=dict(type='bool', default=False), nocache=dict(type='bool', default=False), debug=dict(type='bool', default=False), - timeout=dict(type='int', default=DEFAULT_TIMEOUT) + timeout=dict(type='int') ) mutually_exclusive = [