Specify timeout for _get_token REST API request in cert-mon
In a DC env, when management network connectivity is disrupted for some time, cert-mon's audit greenthreads hang. This happens because of missing timeouts in REST API requests which cause the urlopen to remain hanging forever. As a result, the dc-cert sync status for the subcloud remains unknown indefinitely and the subclouds remain out-of-sync. This commit adds a timeout to the _get_token method to avoid this issue. Change-Id: Idd41cfca6b28287de8328b1ace856cc391778cac Signed-off-by: Jessica Castelino <jessica.castelino@windriver.com> Closes-Bug: 1927735
This commit is contained in:
parent
1399a4bc54
commit
9e9979d96e
|
@ -422,7 +422,7 @@ def get_dc_token(region_name):
|
||||||
|
|
||||||
|
|
||||||
def _get_token(auth_url, auth_project, username, password, user_domain,
|
def _get_token(auth_url, auth_project, username, password, user_domain,
|
||||||
project_domain, region_name):
|
project_domain, region_name, timeout=60):
|
||||||
"""
|
"""
|
||||||
Ask OpenStack Keystone for a token
|
Ask OpenStack Keystone for a token
|
||||||
Returns: token object or None on failure
|
Returns: token object or None on failure
|
||||||
|
@ -453,7 +453,7 @@ def _get_token(auth_url, auth_project, username, password, user_domain,
|
||||||
|
|
||||||
request_info.add_data(payload)
|
request_info.add_data(payload)
|
||||||
|
|
||||||
request = urlopen(request_info)
|
request = urlopen(request_info, timeout=timeout)
|
||||||
# Identity API v3 returns token id in X-Subject-Token
|
# Identity API v3 returns token id in X-Subject-Token
|
||||||
# response header.
|
# response header.
|
||||||
token_id = request.info().getheader('X-Subject-Token')
|
token_id = request.info().getheader('X-Subject-Token')
|
||||||
|
|
Loading…
Reference in New Issue