aboutsummaryrefslogtreecommitdiffstats
path: root/policyhandler/discovery.py
diff options
context:
space:
mode:
authorAlex Shatov <alexs@att.com>2018-12-05 15:23:50 -0500
committerAlex Shatov <alexs@att.com>2018-12-05 15:23:50 -0500
commita39f4e82cef0414f510cf20e25864ac04cc8f055 (patch)
tree759f5a9f51c368456e8d8f3be65dac1951de0bd9 /policyhandler/discovery.py
parent61fe1b8aa4f6e3c2388cbc573f655f60b4c1b5f3 (diff)
4.5.0 policy-handler - multi change
DCAEGEN2-853: - stop reporting the absence of policies or updates as error - this is an expected result == INFO or WARNING DCAEGEN2-903: preparation for TLS on the web-server of policy-handler DCAEGEN2-930: - configurable timeouts for http requests from policy-handler - added configurable pinging on the web-socket to PDP - added healthcheck info on the web-socket - upgraded websocket-client lib to 0.53.0 DCAEGEN2-1017: fixed a bug on policy-filter matching by filter_config_name - refactored and enhanced the unit-tests Change-Id: I111ddc57bb978554ef376cbf916965b6667dad9b Signed-off-by: Alex Shatov <alexs@att.com> Issue-ID: DCAEGEN2-853 Issue-ID: DCAEGEN2-903 Issue-ID: DCAEGEN2-930 Issue-ID: DCAEGEN2-1017
Diffstat (limited to 'policyhandler/discovery.py')
-rw-r--r--policyhandler/discovery.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/policyhandler/discovery.py b/policyhandler/discovery.py
index 5a35525..4c5b64e 100644
--- a/policyhandler/discovery.py
+++ b/policyhandler/discovery.py
@@ -56,7 +56,7 @@ class DiscoveryClient(object):
@staticmethod
def _discover_service(audit, service_name, service_path):
"""find the service record in consul"""
- response = requests.get(service_path)
+ response = requests.get(service_path, timeout=Config.consul_timeout_in_secs)
DiscoveryClient._logger.info(audit.info("response {} from {}: {}".format(
response.status_code, service_path, response.text)))
@@ -113,7 +113,7 @@ class DiscoveryClient(object):
@staticmethod
def _get_value_from_kv(url):
"""get the value from consul-kv at discovery url"""
- response = requests.get(url)
+ response = requests.get(url, timeout=Config.consul_timeout_in_secs)
response.raise_for_status()
data = response.json()
value = base64.b64decode(data[0]["Value"]).decode("utf-8")
@@ -129,6 +129,7 @@ class DiscoveryClient(object):
log_line = "get from {} at {}".format(DiscoveryClient.CONSUL_ENTITY, discovery_url)
DiscoveryClient._logger.info(metrics.metrics_start(log_line))
+ status_code = None
try:
status_code, value = DiscoveryClient._get_value_from_kv(discovery_url)
except Exception as ex: