Browse Source

Add configurable timeout for Drydock client

Adds configs to allow a drydock client to use a non-default read
timeout.

Change-Id: Id4e4a235861165bfb5eb571684c8ce0be4181543
changes/92/617792/1
Bryan Strassner 8 months ago
parent
commit
84d99967bc

+ 2
- 0
charts/shipyard/values.yaml View File

@@ -420,6 +420,8 @@ conf:
420 420
       validation_read_timeout: 300
421 421
       notes_connect_timeout: 5
422 422
       notes_read_timeout: 10
423
+      drydock_client_connect_timeout: 20
424
+      drydock_client_read_timeout: 300
423 425
     airflow:
424 426
       worker_endpoint_scheme: 'http'
425 427
       worker_port: 8793

+ 8
- 0
doc/source/_static/shipyard.conf.sample View File

@@ -385,6 +385,14 @@
385 385
 # Read timeout for a note source URL (in seconds) (integer value)
386 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 397
 [shipyard]
390 398
 

+ 8
- 0
src/bin/shipyard_airflow/etc/shipyard/shipyard.conf.sample View File

@@ -385,6 +385,14 @@
385 385
 # Read timeout for a note source URL (in seconds) (integer value)
386 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 397
 [shipyard]
390 398
 

+ 12
- 0
src/bin/shipyard_airflow/shipyard_airflow/conf/config.py View File

@@ -245,6 +245,18 @@ SECTIONS = [
245 245
                 default=10,
246 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 262
     ConfigSection(

+ 9
- 4
src/bin/shipyard_airflow/shipyard_airflow/control/service_clients.py View File

@@ -14,14 +14,16 @@
14 14
 """Generates clients and client-like objects and functions"""
15 15
 from urllib.parse import urlparse
16 16
 
17
+from oslo_config import cfg
17 18
 from deckhand.client import client as dh_client
18 19
 import drydock_provisioner.drydock_client.client as dd_client
19 20
 import drydock_provisioner.drydock_client.session as dd_session
20 21
 
21
-
22 22
 from shipyard_airflow.control.service_endpoints import Endpoints
23 23
 from shipyard_airflow.control import service_endpoints as svc_endpoints
24 24
 
25
+CONF = cfg.CONF
26
+
25 27
 
26 28
 #
27 29
 # Deckhand Client
@@ -44,7 +46,10 @@ def drydock_client():
44 46
     # Setup the drydock session
45 47
     endpoint = svc_endpoints.get_endpoint(Endpoints.DRYDOCK)
46 48
     dd_url = urlparse(endpoint)
47
-    session = dd_session.DrydockSession(dd_url.hostname,
48
-                                        port=dd_url.port,
49
-                                        auth_gen=_auth_gen)
49
+    session = dd_session.DrydockSession(
50
+        dd_url.hostname,
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 55
     return dd_client.DrydockClient(session)

+ 18
- 3
src/bin/shipyard_airflow/shipyard_airflow/plugins/drydock_base_operator.py View File

@@ -11,6 +11,7 @@
11 11
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 12
 # See the License for the specific language governing permissions and
13 13
 # limitations under the License.
14
+import configparser
14 15
 import copy
15 16
 import pprint
16 17
 import logging
@@ -88,6 +89,8 @@ class DrydockBaseOperator(UcpBaseOperator):
88 89
                                          'container': 'drydock-api'}],
89 90
                   *args, **kwargs)
90 91
         self.drydock_client = drydock_client
92
+        self.drydock_client_connect_timeout = None
93
+        self.drydock_client_read_timeout = None
91 94
         self.drydock_task_id = drydock_task_id
92 95
         self.node_filter = node_filter
93 96
         self.redeploy_server = redeploy_server
@@ -103,6 +106,15 @@ class DrydockBaseOperator(UcpBaseOperator):
103 106
         LOG.debug("Drydock Operator for action %s", self.action_id)
104 107
         # if continue processing is false, don't bother setting up things.
105 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 118
             self._setup_drydock_client()
107 119
 
108 120
     def _continue_processing_flag(self):
@@ -137,9 +149,12 @@ class DrydockBaseOperator(UcpBaseOperator):
137 149
         # information.
138 150
         # The DrydockSession will care for TCP connection pooling
139 151
         # and header management
140
-        dd_session = session.DrydockSession(drydock_url.hostname,
141
-                                            port=drydock_url.port,
142
-                                            auth_gen=self._auth_gen)
152
+        dd_session = session.DrydockSession(
153
+            drydock_url.hostname,
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 159
         # Raise Exception if we are not able to set up the session
145 160
         if not dd_session:

+ 2
- 0
src/bin/shipyard_airflow/tests/unit/plugins/test.conf View File

@@ -10,6 +10,8 @@ profiler = false
10 10
 [requests_config]
11 11
 notes_connect_timeout = 5
12 12
 notes_read_timeout = 10
13
+drydock_client_connect_timeout = 20
14
+drydock_client_read_timeout = 300
13 15
 
14 16
 [keystone_authtoken]
15 17
 auth_section = keystone_authtoken

Loading…
Cancel
Save