From 01050dc01fa8558eb453c48faa2a8efd398c5367 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Wed, 27 Nov 2019 14:52:03 +0000 Subject: [PATCH] Support configuration of Docker client timeout Adds support for configuration of the Docker client timeout via 'docker_client_timeout'. This change also increases the default timeout to 120 seconds, as we sometimes see timeouts in CI and heavily loaded or underpowered environments. Increasing 'docker_client_timeout' further may be helpful in cases where Docker reports 'Read timed out'. Change-Id: I73745771078cb2c0ebae2b1d87ba2c4c12958d82 Closes-Bug: #1809844 --- ansible/group_vars/all.yml | 3 +++ ansible/library/kolla_docker.py | 10 +++++++++- etc/kolla/globals.yml | 2 ++ .../notes/docker-client-timeout-dc221b2d350efad8.yaml | 8 ++++++++ tests/test_kolla_docker.py | 1 + 5 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/docker-client-timeout-dc221b2d350efad8.yaml diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 9315b8bf2d..f7846ea282 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -96,6 +96,8 @@ docker_namespace: "kolla" docker_registry_username: docker_registry_insecure: "{{ 'yes' if docker_registry else 'no' }}" docker_runtime_directory: "" +# Docker client timeout in seconds. +docker_client_timeout: 120 # Retention settings for Docker logs docker_log_max_file: "5" @@ -127,6 +129,7 @@ docker_common_options: restart_policy: "{{ docker_restart_policy }}" restart_retries: "{{ docker_restart_policy_retry }}" graceful_timeout: "{{ docker_graceful_timeout }}" + client_timeout: "{{ docker_client_timeout }}" #################### # Dimensions options diff --git a/ansible/library/kolla_docker.py b/ansible/library/kolla_docker.py index 249a3477f5..fe0264c38c 100644 --- a/ansible/library/kolla_docker.py +++ b/ansible/library/kolla_docker.py @@ -201,6 +201,12 @@ options: required: False default: False type: bool + client_timeout: + description: + - Docker client timeout in seconds + required: False + default: 120 + type: int author: Sam Yaple ''' @@ -252,7 +258,8 @@ class DockerWorker(object): # tls_config = self.generate_tls() options = { - 'version': self.params.get('api_version') + 'version': self.params.get('api_version'), + 'timeout': self.params.get('client_timeout'), } self.dc = get_docker_client()(**options) @@ -957,6 +964,7 @@ def generate_module(): volumes_from=dict(required=False, type='list'), dimensions=dict(required=False, type='dict', default=dict()), tty=dict(required=False, type='bool', default=False), + client_timeout=dict(required=False, type='int', default=120), ) required_if = [ ['action', 'pull_image', ['image']], diff --git a/etc/kolla/globals.yml b/etc/kolla/globals.yml index 6315cfbf85..b1be6afaa2 100644 --- a/etc/kolla/globals.yml +++ b/etc/kolla/globals.yml @@ -57,6 +57,8 @@ #docker_registry_insecure: "yes" #docker_registry_username: "sam" #docker_registry_password: "correcthorsebatterystaple" +# Docker client timeout in seconds. +#docker_client_timeout: 120 #docker_configure_for_zun: "no" diff --git a/releasenotes/notes/docker-client-timeout-dc221b2d350efad8.yaml b/releasenotes/notes/docker-client-timeout-dc221b2d350efad8.yaml new file mode 100644 index 0000000000..1dcd9b2eb6 --- /dev/null +++ b/releasenotes/notes/docker-client-timeout-dc221b2d350efad8.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + Fixes an issue with Docker client timeouts where Docker reports 'Read + timed out'. The client timeout may be configured via + ``docker_client_timeout``. The default timeout has been increased to 120 + seconds. See `bug + `__ for details. diff --git a/tests/test_kolla_docker.py b/tests/test_kolla_docker.py index 8fad2aa82e..7fb9b4f0bc 100644 --- a/tests/test_kolla_docker.py +++ b/tests/test_kolla_docker.py @@ -98,6 +98,7 @@ class ModuleArgsTest(base.BaseTestCase): volumes_from=dict(required=False, type='list'), dimensions=dict(required=False, type='dict', default=dict()), tty=dict(required=False, type='bool', default=False), + client_timeout=dict(required=False, type='int', default=120), ) required_if = [ ['action', 'pull_image', ['image']],