Make Request Timeout Configurable
As the size of the YAMLs increases, the amount of time needed to process the request increased as well. Hence there is a need to make 'timeout' configurable for the deckhand client. Change-Id: Iab91091cd8b9a900ad0daeac22e435d4e5c9c97d
This commit is contained in:
parent
5ca2b349a2
commit
25236ac89b
|
@ -334,6 +334,11 @@ conf:
|
||||||
auth_section: keystone_authtoken
|
auth_section: keystone_authtoken
|
||||||
auth_version: v3
|
auth_version: v3
|
||||||
memcache_security_strategy: ENCRYPT
|
memcache_security_strategy: ENCRYPT
|
||||||
|
requests_config:
|
||||||
|
deckhand_client_connect_timeout: 5
|
||||||
|
deckhand_client_read_timeout: 300
|
||||||
|
validation_connect_timeout: 5
|
||||||
|
validation_read_timeout: 300
|
||||||
airflow:
|
airflow:
|
||||||
override:
|
override:
|
||||||
append:
|
append:
|
||||||
|
|
|
@ -277,6 +277,21 @@
|
||||||
#log_level = 10
|
#log_level = 10
|
||||||
|
|
||||||
|
|
||||||
|
[requests_config]
|
||||||
|
# Deckhand client connect timeout (in seconds)
|
||||||
|
#deckhand_client_connect_timeout = 5
|
||||||
|
|
||||||
|
# Deckhand client timeout (in seconds) for GET,
|
||||||
|
# PUT, POST and DELETE request
|
||||||
|
#deckhand_client_read_timeout = 300
|
||||||
|
|
||||||
|
# UCP component validation connect timeout (in seconds)
|
||||||
|
#validation_connect_timeout = 5
|
||||||
|
|
||||||
|
# UCP component validation timeout (in seconds)
|
||||||
|
#validation_read_timeout = 300
|
||||||
|
|
||||||
|
|
||||||
[shipyard]
|
[shipyard]
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -77,7 +77,7 @@ SECTIONS = [
|
||||||
help=(
|
help=(
|
||||||
'The service type for the service playing the role '
|
'The service type for the service playing the role '
|
||||||
'of Shipyard. The specified type is used to perform '
|
'of Shipyard. The specified type is used to perform '
|
||||||
'the service lookup in the Keystone service catalog. '
|
'the service lookup in the Keystone service catalog.'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
@ -92,7 +92,7 @@ SECTIONS = [
|
||||||
help=(
|
help=(
|
||||||
'The service type for the service playing the role '
|
'The service type for the service playing the role '
|
||||||
'of Deckhand. The specified type is used to perform '
|
'of Deckhand. The specified type is used to perform '
|
||||||
'the service lookup in the Keystone service catalog. '
|
'the service lookup in the Keystone service catalog.'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
@ -107,7 +107,7 @@ SECTIONS = [
|
||||||
help=(
|
help=(
|
||||||
'The service type for the service playing the role '
|
'The service type for the service playing the role '
|
||||||
'of Armada. The specified type is used to perform '
|
'of Armada. The specified type is used to perform '
|
||||||
'the service lookup in the Keystone service catalog. '
|
'the service lookup in the Keystone service catalog.'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
@ -122,7 +122,7 @@ SECTIONS = [
|
||||||
help=(
|
help=(
|
||||||
'The service type for the service playing the role '
|
'The service type for the service playing the role '
|
||||||
'of Drydock. The specified type is used to perform '
|
'of Drydock. The specified type is used to perform '
|
||||||
'the service lookup in the Keystone service catalog. '
|
'the service lookup in the Keystone service catalog.'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
cfg.IntOpt(
|
cfg.IntOpt(
|
||||||
|
@ -182,6 +182,35 @@ SECTIONS = [
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
|
ConfigSection(
|
||||||
|
name='requests_config',
|
||||||
|
title='Requests Configuration',
|
||||||
|
options=[
|
||||||
|
cfg.IntOpt(
|
||||||
|
'deckhand_client_connect_timeout',
|
||||||
|
default=5,
|
||||||
|
help='Deckhand client connect timeout (in seconds)'
|
||||||
|
),
|
||||||
|
cfg.IntOpt(
|
||||||
|
'deckhand_client_read_timeout',
|
||||||
|
default=300,
|
||||||
|
help=(
|
||||||
|
'Deckhand client timeout (in seconds) for GET, '
|
||||||
|
'PUT, POST and DELETE request'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
cfg.IntOpt(
|
||||||
|
'validation_connect_timeout',
|
||||||
|
default=5,
|
||||||
|
help='UCP component validation connect timeout (in seconds)'
|
||||||
|
),
|
||||||
|
cfg.IntOpt(
|
||||||
|
'validation_read_timeout',
|
||||||
|
default=300,
|
||||||
|
help='UCP component validation timeout (in seconds)'
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -437,13 +437,13 @@ class ConfigdocsHelper(object):
|
||||||
'content-type': 'application/json'
|
'content-type': 'application/json'
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO: We will need to make timeout a configurable value as it
|
|
||||||
# will differ from site to site based on the size of the rendered
|
|
||||||
# document
|
|
||||||
# Note that 30 seconds is not sufficient to complete validations.
|
|
||||||
# Hence we are increaing the default timeout to 60 seconds.
|
|
||||||
http_resp = requests.post(
|
http_resp = requests.post(
|
||||||
url, headers=headers, data=design_reference, timeout=(5, 60))
|
url,
|
||||||
|
headers=headers,
|
||||||
|
data=design_reference,
|
||||||
|
timeout=(
|
||||||
|
CONF.requests_config.validation_connect_timeout,
|
||||||
|
CONF.requests_config.validation_read_timeout))
|
||||||
# 400 response is "valid" failure to validate. > 400 is a problem.
|
# 400 response is "valid" failure to validate. > 400 is a problem.
|
||||||
if http_resp.status_code > 400:
|
if http_resp.status_code > 400:
|
||||||
http_resp.raise_for_status()
|
http_resp.raise_for_status()
|
||||||
|
|
|
@ -362,11 +362,14 @@ class DeckhandClient(object):
|
||||||
headers['content-type'] = 'application/x-yaml'
|
headers['content-type'] = 'application/x-yaml'
|
||||||
|
|
||||||
DeckhandClient._log_request('PUT', url, params)
|
DeckhandClient._log_request('PUT', url, params)
|
||||||
response = requests.put(url,
|
response = requests.put(
|
||||||
params=params,
|
url,
|
||||||
headers=headers,
|
params=params,
|
||||||
data=document_data,
|
headers=headers,
|
||||||
timeout=(5, 30))
|
data=document_data,
|
||||||
|
timeout=(
|
||||||
|
CONF.requests_config.deckhand_client_connect_timeout,
|
||||||
|
CONF.requests_config.deckhand_client_read_timeout))
|
||||||
return response
|
return response
|
||||||
except RequestException as rex:
|
except RequestException as rex:
|
||||||
LOG.error(rex)
|
LOG.error(rex)
|
||||||
|
@ -386,10 +389,13 @@ class DeckhandClient(object):
|
||||||
}
|
}
|
||||||
|
|
||||||
DeckhandClient._log_request('GET', url, params)
|
DeckhandClient._log_request('GET', url, params)
|
||||||
response = requests.get(url,
|
response = requests.get(
|
||||||
params=params,
|
url,
|
||||||
headers=headers,
|
params=params,
|
||||||
timeout=(5, 30))
|
headers=headers,
|
||||||
|
timeout=(
|
||||||
|
CONF.requests_config.deckhand_client_connect_timeout,
|
||||||
|
CONF.requests_config.deckhand_client_read_timeout))
|
||||||
return response
|
return response
|
||||||
except RequestException as rex:
|
except RequestException as rex:
|
||||||
LOG.error(rex)
|
LOG.error(rex)
|
||||||
|
@ -411,11 +417,14 @@ class DeckhandClient(object):
|
||||||
headers['content-type'] = 'application/x-yaml'
|
headers['content-type'] = 'application/x-yaml'
|
||||||
|
|
||||||
DeckhandClient._log_request('POST', url, params)
|
DeckhandClient._log_request('POST', url, params)
|
||||||
response = requests.post(url,
|
response = requests.post(
|
||||||
params=params,
|
url,
|
||||||
headers=headers,
|
params=params,
|
||||||
data=document_data,
|
headers=headers,
|
||||||
timeout=(5, 30))
|
data=document_data,
|
||||||
|
timeout=(
|
||||||
|
CONF.requests_config.deckhand_client_connect_timeout,
|
||||||
|
CONF.requests_config.deckhand_client_read_timeout))
|
||||||
return response
|
return response
|
||||||
except RequestException as rex:
|
except RequestException as rex:
|
||||||
LOG.error(rex)
|
LOG.error(rex)
|
||||||
|
@ -434,10 +443,13 @@ class DeckhandClient(object):
|
||||||
}
|
}
|
||||||
|
|
||||||
DeckhandClient._log_request('DELETE', url, params)
|
DeckhandClient._log_request('DELETE', url, params)
|
||||||
response = requests.delete(url,
|
response = requests.delete(
|
||||||
params=params,
|
url,
|
||||||
headers=headers,
|
params=params,
|
||||||
timeout=(5, 30))
|
headers=headers,
|
||||||
|
timeout=(
|
||||||
|
CONF.requests_config.deckhand_client_connect_timeout,
|
||||||
|
CONF.requests_config.deckhand_client_read_timeout))
|
||||||
return response
|
return response
|
||||||
except RequestException as rex:
|
except RequestException as rex:
|
||||||
LOG.error(rex)
|
LOG.error(rex)
|
||||||
|
|
|
@ -35,6 +35,11 @@ project_domain_name = default
|
||||||
project_name = service
|
project_name = service
|
||||||
user_domain_name = default
|
user_domain_name = default
|
||||||
username = shipyard
|
username = shipyard
|
||||||
|
[requests_config]
|
||||||
|
deckhand_client_connect_timeout=5
|
||||||
|
deckhand_client_read_timeout=300
|
||||||
|
validation_connect_timeout=5
|
||||||
|
validation_read_timeout=300
|
||||||
[shipyard]
|
[shipyard]
|
||||||
service_type = shipyard
|
service_type = shipyard
|
||||||
|
|
||||||
|
|
|
@ -37,5 +37,10 @@ project_domain_name = default
|
||||||
project_name = service
|
project_name = service
|
||||||
user_domain_name = default
|
user_domain_name = default
|
||||||
username = shipyard
|
username = shipyard
|
||||||
|
[requests_config]
|
||||||
|
deckhand_client_connect_timeout=5
|
||||||
|
deckhand_client_read_timeout=300
|
||||||
|
validation_connect_timeout=5
|
||||||
|
validation_read_timeout=300
|
||||||
[shipyard]
|
[shipyard]
|
||||||
service_type = shipyard
|
service_type = shipyard
|
||||||
|
|
Loading…
Reference in New Issue