From ae274e51c49f18d1ac34b7181cdf569f2fbe8e90 Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Mon, 2 Dec 2019 14:50:25 -0800 Subject: [PATCH] [neighbor advertiser] catch all exceptions while trying https endpoint (#757) * [neighbor advertiser] catch all exceptions while trying https endpoint When connecting https endpoint failed, we need to try http endpoint. Therefore we need to catch all exceptions. Signed-off-by: Ying Xie * raise exception if https returned non-success status code --- scripts/neighbor_advertiser | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/neighbor_advertiser b/scripts/neighbor_advertiser index 6ebd8808de..df46ea7916 100644 --- a/scripts/neighbor_advertiser +++ b/scripts/neighbor_advertiser @@ -21,7 +21,6 @@ import sonic_device_util from swsssdk import ConfigDBConnector from swsssdk import SonicV2Connector from netaddr import IPAddress, IPNetwork -from requests.exceptions import ConnectTimeout # @@ -356,8 +355,9 @@ def wrapped_ferret_request(request_slice, https_endpoint, http_endpoint): json=request_slice, timeout=DEFAULT_REQUEST_TIMEOUT, verify=False) - except ConnectTimeout: - log_info("HTTPS Ferret endpoint not found, trying HTTP...") + response.raise_for_status() + except Exception as e: + log_info("Connect HTTPS Ferret endpoint failed (error: {}), trying HTTP...".format(e)) response = requests.post(http_endpoint, json=request_slice, timeout=DEFAULT_REQUEST_TIMEOUT)