Add configurable timeout for Drydock client
Adds configs to allow a drydock client to use a non-default read timeout. Change-Id: Id4e4a235861165bfb5eb571684c8ce0be4181543
This commit is contained in:
parent
077bf7653a
commit
84d99967bc
|
@ -420,6 +420,8 @@ conf:
|
||||||
validation_read_timeout: 300
|
validation_read_timeout: 300
|
||||||
notes_connect_timeout: 5
|
notes_connect_timeout: 5
|
||||||
notes_read_timeout: 10
|
notes_read_timeout: 10
|
||||||
|
drydock_client_connect_timeout: 20
|
||||||
|
drydock_client_read_timeout: 300
|
||||||
airflow:
|
airflow:
|
||||||
worker_endpoint_scheme: 'http'
|
worker_endpoint_scheme: 'http'
|
||||||
worker_port: 8793
|
worker_port: 8793
|
||||||
|
|
|
@ -385,6 +385,14 @@
|
||||||
# Read timeout for a note source URL (in seconds) (integer value)
|
# Read timeout for a note source URL (in seconds) (integer value)
|
||||||
#notes_read_timeout = 10
|
#notes_read_timeout = 10
|
||||||
|
|
||||||
|
# Connect timeout used for connecting to Drydock using the Drydock client (in
|
||||||
|
# seconds) (integer value)
|
||||||
|
#drydock_client_connect_timeout = 20
|
||||||
|
|
||||||
|
# Read timeout used for responses from Drydock using the Drydock client (in
|
||||||
|
# seconds) (integer value)
|
||||||
|
#drydock_client_read_timeout = 300
|
||||||
|
|
||||||
|
|
||||||
[shipyard]
|
[shipyard]
|
||||||
|
|
||||||
|
|
|
@ -385,6 +385,14 @@
|
||||||
# Read timeout for a note source URL (in seconds) (integer value)
|
# Read timeout for a note source URL (in seconds) (integer value)
|
||||||
#notes_read_timeout = 10
|
#notes_read_timeout = 10
|
||||||
|
|
||||||
|
# Connect timeout used for connecting to Drydock using the Drydock client (in
|
||||||
|
# seconds) (integer value)
|
||||||
|
#drydock_client_connect_timeout = 20
|
||||||
|
|
||||||
|
# Read timeout used for responses from Drydock using the Drydock client (in
|
||||||
|
# seconds) (integer value)
|
||||||
|
#drydock_client_read_timeout = 300
|
||||||
|
|
||||||
|
|
||||||
[shipyard]
|
[shipyard]
|
||||||
|
|
||||||
|
|
|
@ -245,6 +245,18 @@ SECTIONS = [
|
||||||
default=10,
|
default=10,
|
||||||
help='Read timeout for a note source URL (in seconds)'
|
help='Read timeout for a note source URL (in seconds)'
|
||||||
),
|
),
|
||||||
|
cfg.IntOpt(
|
||||||
|
'drydock_client_connect_timeout',
|
||||||
|
default=20,
|
||||||
|
help=('Connect timeout used for connecting to Drydock using '
|
||||||
|
'the Drydock client (in seconds)')
|
||||||
|
),
|
||||||
|
cfg.IntOpt(
|
||||||
|
'drydock_client_read_timeout',
|
||||||
|
default=300,
|
||||||
|
help=('Read timeout used for responses from Drydock using '
|
||||||
|
'the Drydock client (in seconds)')
|
||||||
|
),
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
ConfigSection(
|
ConfigSection(
|
||||||
|
|
|
@ -14,14 +14,16 @@
|
||||||
"""Generates clients and client-like objects and functions"""
|
"""Generates clients and client-like objects and functions"""
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
from deckhand.client import client as dh_client
|
from deckhand.client import client as dh_client
|
||||||
import drydock_provisioner.drydock_client.client as dd_client
|
import drydock_provisioner.drydock_client.client as dd_client
|
||||||
import drydock_provisioner.drydock_client.session as dd_session
|
import drydock_provisioner.drydock_client.session as dd_session
|
||||||
|
|
||||||
|
|
||||||
from shipyard_airflow.control.service_endpoints import Endpoints
|
from shipyard_airflow.control.service_endpoints import Endpoints
|
||||||
from shipyard_airflow.control import service_endpoints as svc_endpoints
|
from shipyard_airflow.control import service_endpoints as svc_endpoints
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Deckhand Client
|
# Deckhand Client
|
||||||
|
@ -44,7 +46,10 @@ def drydock_client():
|
||||||
# Setup the drydock session
|
# Setup the drydock session
|
||||||
endpoint = svc_endpoints.get_endpoint(Endpoints.DRYDOCK)
|
endpoint = svc_endpoints.get_endpoint(Endpoints.DRYDOCK)
|
||||||
dd_url = urlparse(endpoint)
|
dd_url = urlparse(endpoint)
|
||||||
session = dd_session.DrydockSession(dd_url.hostname,
|
session = dd_session.DrydockSession(
|
||||||
|
dd_url.hostname,
|
||||||
port=dd_url.port,
|
port=dd_url.port,
|
||||||
auth_gen=_auth_gen)
|
auth_gen=_auth_gen,
|
||||||
|
timeout=(CONF.requests_config.drydock_client_connect_timeout,
|
||||||
|
CONF.requests_config.drydock_client_read_timeout))
|
||||||
return dd_client.DrydockClient(session)
|
return dd_client.DrydockClient(session)
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
import configparser
|
||||||
import copy
|
import copy
|
||||||
import pprint
|
import pprint
|
||||||
import logging
|
import logging
|
||||||
|
@ -88,6 +89,8 @@ class DrydockBaseOperator(UcpBaseOperator):
|
||||||
'container': 'drydock-api'}],
|
'container': 'drydock-api'}],
|
||||||
*args, **kwargs)
|
*args, **kwargs)
|
||||||
self.drydock_client = drydock_client
|
self.drydock_client = drydock_client
|
||||||
|
self.drydock_client_connect_timeout = None
|
||||||
|
self.drydock_client_read_timeout = None
|
||||||
self.drydock_task_id = drydock_task_id
|
self.drydock_task_id = drydock_task_id
|
||||||
self.node_filter = node_filter
|
self.node_filter = node_filter
|
||||||
self.redeploy_server = redeploy_server
|
self.redeploy_server = redeploy_server
|
||||||
|
@ -103,6 +106,15 @@ class DrydockBaseOperator(UcpBaseOperator):
|
||||||
LOG.debug("Drydock Operator for action %s", self.action_id)
|
LOG.debug("Drydock Operator for action %s", self.action_id)
|
||||||
# if continue processing is false, don't bother setting up things.
|
# if continue processing is false, don't bother setting up things.
|
||||||
if self._continue_processing_flag():
|
if self._continue_processing_flag():
|
||||||
|
# Retrieve config values from shipyard configuration.
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read(self.shipyard_conf)
|
||||||
|
self.drydock_client_connect_timeout = int(config.get(
|
||||||
|
'requests_config', 'drydock_client_connect_timeout'))
|
||||||
|
self.drydock_client_read_timeout = int(config.get(
|
||||||
|
'requests_config', 'drydock_client_read_timeout'))
|
||||||
|
|
||||||
|
# Setup the drydock client
|
||||||
self._setup_drydock_client()
|
self._setup_drydock_client()
|
||||||
|
|
||||||
def _continue_processing_flag(self):
|
def _continue_processing_flag(self):
|
||||||
|
@ -137,9 +149,12 @@ class DrydockBaseOperator(UcpBaseOperator):
|
||||||
# information.
|
# information.
|
||||||
# The DrydockSession will care for TCP connection pooling
|
# The DrydockSession will care for TCP connection pooling
|
||||||
# and header management
|
# and header management
|
||||||
dd_session = session.DrydockSession(drydock_url.hostname,
|
dd_session = session.DrydockSession(
|
||||||
|
drydock_url.hostname,
|
||||||
port=drydock_url.port,
|
port=drydock_url.port,
|
||||||
auth_gen=self._auth_gen)
|
auth_gen=self._auth_gen,
|
||||||
|
timeout=(self.drydock_client_connect_timeout,
|
||||||
|
self.drydock_client_read_timeout))
|
||||||
|
|
||||||
# Raise Exception if we are not able to set up the session
|
# Raise Exception if we are not able to set up the session
|
||||||
if not dd_session:
|
if not dd_session:
|
||||||
|
|
|
@ -10,6 +10,8 @@ profiler = false
|
||||||
[requests_config]
|
[requests_config]
|
||||||
notes_connect_timeout = 5
|
notes_connect_timeout = 5
|
||||||
notes_read_timeout = 10
|
notes_read_timeout = 10
|
||||||
|
drydock_client_connect_timeout = 20
|
||||||
|
drydock_client_read_timeout = 300
|
||||||
|
|
||||||
[keystone_authtoken]
|
[keystone_authtoken]
|
||||||
auth_section = keystone_authtoken
|
auth_section = keystone_authtoken
|
||||||
|
|
Loading…
Reference in New Issue