Skip to content

Commit

Permalink
[neighbor advertiser] catch all exceptions while trying https endpoint (
Browse files Browse the repository at this point in the history
#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 <[email protected]>

* raise exception if https returned non-success status code
  • Loading branch information
yxieca committed Dec 2, 2019
1 parent e548793 commit ae274e5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scripts/neighbor_advertiser
Original file line number Diff line number Diff line change
Expand Up @@ -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


#
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ae274e5

Please sign in to comment.