summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Strassner <bryan.strassner@gmail.com>2018-11-13 13:10:07 -0600
committerBryan Strassner <bryan.strassner@gmail.com>2018-11-13 13:10:07 -0600
commit84d99967bca73bef43e9ed70adc7e47cbd53ecf3 (patch)
tree1d45badbac773c2b1a304e1ebc4e7f75da3a03dc
parent077bf7653af9202e72f523db31c9e05686e673fc (diff)
Add configurable timeout for Drydock client
Adds configs to allow a drydock client to use a non-default read timeout. Change-Id: Id4e4a235861165bfb5eb571684c8ce0be4181543
Notes
Notes (review): Code-Review+2: Scott Hussey <sthussey@att.com> Code-Review+2: Aaron Sheffield <ajs@sheffieldfamily.net> Workflow+1: Aaron Sheffield <ajs@sheffieldfamily.net> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 13 Nov 2018 19:47:00 +0000 Reviewed-on: https://review.openstack.org/617792 Project: openstack/airship-shipyard Branch: refs/heads/master
-rw-r--r--charts/shipyard/values.yaml2
-rw-r--r--doc/source/_static/shipyard.conf.sample8
-rw-r--r--src/bin/shipyard_airflow/etc/shipyard/shipyard.conf.sample8
-rw-r--r--src/bin/shipyard_airflow/shipyard_airflow/conf/config.py12
-rw-r--r--src/bin/shipyard_airflow/shipyard_airflow/control/service_clients.py13
-rw-r--r--src/bin/shipyard_airflow/shipyard_airflow/plugins/drydock_base_operator.py21
-rw-r--r--src/bin/shipyard_airflow/tests/unit/plugins/test.conf2
7 files changed, 59 insertions, 7 deletions
diff --git a/charts/shipyard/values.yaml b/charts/shipyard/values.yaml
index 32b51a4..fc51894 100644
--- a/charts/shipyard/values.yaml
+++ b/charts/shipyard/values.yaml
@@ -420,6 +420,8 @@ conf:
420 validation_read_timeout: 300 420 validation_read_timeout: 300
421 notes_connect_timeout: 5 421 notes_connect_timeout: 5
422 notes_read_timeout: 10 422 notes_read_timeout: 10
423 drydock_client_connect_timeout: 20
424 drydock_client_read_timeout: 300
423 airflow: 425 airflow:
424 worker_endpoint_scheme: 'http' 426 worker_endpoint_scheme: 'http'
425 worker_port: 8793 427 worker_port: 8793
diff --git a/doc/source/_static/shipyard.conf.sample b/doc/source/_static/shipyard.conf.sample
index e90ff37..9d455f3 100644
--- a/doc/source/_static/shipyard.conf.sample
+++ b/doc/source/_static/shipyard.conf.sample
@@ -385,6 +385,14 @@
385# Read timeout for a note source URL (in seconds) (integer value) 385# Read timeout for a note source URL (in seconds) (integer value)
386#notes_read_timeout = 10 386#notes_read_timeout = 10
387 387
388# Connect timeout used for connecting to Drydock using the Drydock client (in
389# seconds) (integer value)
390#drydock_client_connect_timeout = 20
391
392# Read timeout used for responses from Drydock using the Drydock client (in
393# seconds) (integer value)
394#drydock_client_read_timeout = 300
395
388 396
389[shipyard] 397[shipyard]
390 398
diff --git a/src/bin/shipyard_airflow/etc/shipyard/shipyard.conf.sample b/src/bin/shipyard_airflow/etc/shipyard/shipyard.conf.sample
index e90ff37..9d455f3 100644
--- a/src/bin/shipyard_airflow/etc/shipyard/shipyard.conf.sample
+++ b/src/bin/shipyard_airflow/etc/shipyard/shipyard.conf.sample
@@ -385,6 +385,14 @@
385# Read timeout for a note source URL (in seconds) (integer value) 385# Read timeout for a note source URL (in seconds) (integer value)
386#notes_read_timeout = 10 386#notes_read_timeout = 10
387 387
388# Connect timeout used for connecting to Drydock using the Drydock client (in
389# seconds) (integer value)
390#drydock_client_connect_timeout = 20
391
392# Read timeout used for responses from Drydock using the Drydock client (in
393# seconds) (integer value)
394#drydock_client_read_timeout = 300
395
388 396
389[shipyard] 397[shipyard]
390 398
diff --git a/src/bin/shipyard_airflow/shipyard_airflow/conf/config.py b/src/bin/shipyard_airflow/shipyard_airflow/conf/config.py
index 7dfa2a8..89b1224 100644
--- a/src/bin/shipyard_airflow/shipyard_airflow/conf/config.py
+++ b/src/bin/shipyard_airflow/shipyard_airflow/conf/config.py
@@ -245,6 +245,18 @@ SECTIONS = [
245 default=10, 245 default=10,
246 help='Read timeout for a note source URL (in seconds)' 246 help='Read timeout for a note source URL (in seconds)'
247 ), 247 ),
248 cfg.IntOpt(
249 'drydock_client_connect_timeout',
250 default=20,
251 help=('Connect timeout used for connecting to Drydock using '
252 'the Drydock client (in seconds)')
253 ),
254 cfg.IntOpt(
255 'drydock_client_read_timeout',
256 default=300,
257 help=('Read timeout used for responses from Drydock using '
258 'the Drydock client (in seconds)')
259 ),
248 ] 260 ]
249 ), 261 ),
250 ConfigSection( 262 ConfigSection(
diff --git a/src/bin/shipyard_airflow/shipyard_airflow/control/service_clients.py b/src/bin/shipyard_airflow/shipyard_airflow/control/service_clients.py
index 0b4faea..cb2db4e 100644
--- a/src/bin/shipyard_airflow/shipyard_airflow/control/service_clients.py
+++ b/src/bin/shipyard_airflow/shipyard_airflow/control/service_clients.py
@@ -14,14 +14,16 @@
14"""Generates clients and client-like objects and functions""" 14"""Generates clients and client-like objects and functions"""
15from urllib.parse import urlparse 15from urllib.parse import urlparse
16 16
17from oslo_config import cfg
17from deckhand.client import client as dh_client 18from deckhand.client import client as dh_client
18import drydock_provisioner.drydock_client.client as dd_client 19import drydock_provisioner.drydock_client.client as dd_client
19import drydock_provisioner.drydock_client.session as dd_session 20import drydock_provisioner.drydock_client.session as dd_session
20 21
21
22from shipyard_airflow.control.service_endpoints import Endpoints 22from shipyard_airflow.control.service_endpoints import Endpoints
23from shipyard_airflow.control import service_endpoints as svc_endpoints 23from shipyard_airflow.control import service_endpoints as svc_endpoints
24 24
25CONF = cfg.CONF
26
25 27
26# 28#
27# Deckhand Client 29# Deckhand Client
@@ -44,7 +46,10 @@ def drydock_client():
44 # Setup the drydock session 46 # Setup the drydock session
45 endpoint = svc_endpoints.get_endpoint(Endpoints.DRYDOCK) 47 endpoint = svc_endpoints.get_endpoint(Endpoints.DRYDOCK)
46 dd_url = urlparse(endpoint) 48 dd_url = urlparse(endpoint)
47 session = dd_session.DrydockSession(dd_url.hostname, 49 session = dd_session.DrydockSession(
48 port=dd_url.port, 50 dd_url.hostname,
49 auth_gen=_auth_gen) 51 port=dd_url.port,
52 auth_gen=_auth_gen,
53 timeout=(CONF.requests_config.drydock_client_connect_timeout,
54 CONF.requests_config.drydock_client_read_timeout))
50 return dd_client.DrydockClient(session) 55 return dd_client.DrydockClient(session)
diff --git a/src/bin/shipyard_airflow/shipyard_airflow/plugins/drydock_base_operator.py b/src/bin/shipyard_airflow/shipyard_airflow/plugins/drydock_base_operator.py
index 26a848f..3c1e601 100644
--- a/src/bin/shipyard_airflow/shipyard_airflow/plugins/drydock_base_operator.py
+++ b/src/bin/shipyard_airflow/shipyard_airflow/plugins/drydock_base_operator.py
@@ -11,6 +11,7 @@
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and 12# See the License for the specific language governing permissions and
13# limitations under the License. 13# limitations under the License.
14import configparser
14import copy 15import copy
15import pprint 16import pprint
16import logging 17import logging
@@ -88,6 +89,8 @@ class DrydockBaseOperator(UcpBaseOperator):
88 'container': 'drydock-api'}], 89 'container': 'drydock-api'}],
89 *args, **kwargs) 90 *args, **kwargs)
90 self.drydock_client = drydock_client 91 self.drydock_client = drydock_client
92 self.drydock_client_connect_timeout = None
93 self.drydock_client_read_timeout = None
91 self.drydock_task_id = drydock_task_id 94 self.drydock_task_id = drydock_task_id
92 self.node_filter = node_filter 95 self.node_filter = node_filter
93 self.redeploy_server = redeploy_server 96 self.redeploy_server = redeploy_server
@@ -103,6 +106,15 @@ class DrydockBaseOperator(UcpBaseOperator):
103 LOG.debug("Drydock Operator for action %s", self.action_id) 106 LOG.debug("Drydock Operator for action %s", self.action_id)
104 # if continue processing is false, don't bother setting up things. 107 # if continue processing is false, don't bother setting up things.
105 if self._continue_processing_flag(): 108 if self._continue_processing_flag():
109 # Retrieve config values from shipyard configuration.
110 config = configparser.ConfigParser()
111 config.read(self.shipyard_conf)
112 self.drydock_client_connect_timeout = int(config.get(
113 'requests_config', 'drydock_client_connect_timeout'))
114 self.drydock_client_read_timeout = int(config.get(
115 'requests_config', 'drydock_client_read_timeout'))
116
117 # Setup the drydock client
106 self._setup_drydock_client() 118 self._setup_drydock_client()
107 119
108 def _continue_processing_flag(self): 120 def _continue_processing_flag(self):
@@ -137,9 +149,12 @@ class DrydockBaseOperator(UcpBaseOperator):
137 # information. 149 # information.
138 # The DrydockSession will care for TCP connection pooling 150 # The DrydockSession will care for TCP connection pooling
139 # and header management 151 # and header management
140 dd_session = session.DrydockSession(drydock_url.hostname, 152 dd_session = session.DrydockSession(
141 port=drydock_url.port, 153 drydock_url.hostname,
142 auth_gen=self._auth_gen) 154 port=drydock_url.port,
155 auth_gen=self._auth_gen,
156 timeout=(self.drydock_client_connect_timeout,
157 self.drydock_client_read_timeout))
143 158
144 # Raise Exception if we are not able to set up the session 159 # Raise Exception if we are not able to set up the session
145 if not dd_session: 160 if not dd_session:
diff --git a/src/bin/shipyard_airflow/tests/unit/plugins/test.conf b/src/bin/shipyard_airflow/tests/unit/plugins/test.conf
index 5da374a..46a53f8 100644
--- a/src/bin/shipyard_airflow/tests/unit/plugins/test.conf
+++ b/src/bin/shipyard_airflow/tests/unit/plugins/test.conf
@@ -10,6 +10,8 @@ profiler = false
10[requests_config] 10[requests_config]
11notes_connect_timeout = 5 11notes_connect_timeout = 5
12notes_read_timeout = 10 12notes_read_timeout = 10
13drydock_client_connect_timeout = 20
14drydock_client_read_timeout = 300
13 15
14[keystone_authtoken] 16[keystone_authtoken]
15auth_section = keystone_authtoken 17auth_section = keystone_authtoken