Skip to content

Commit 5214a8d

Browse files
authored
[neighbor advertiser] remove http endpoint access (sonic-net#792)
* [neighbor advertiser] remove http endpoint access Signed-off-by: Ying Xie <[email protected]> * Remove obsolete comment
1 parent bafaaed commit 5214a8d

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

scripts/neighbor_advertiser

+8-26
Original file line numberDiff line numberDiff line change
@@ -340,37 +340,20 @@ def construct_neighbor_advertiser_slice():
340340
return slice_obj
341341

342342

343-
def wrapped_ferret_request(request_slice, https_endpoint, http_endpoint):
344-
"""
345-
Attempts to reach ferret by first trying HTTPS, failing over to HTTP in
346-
case of failure (e.g. timeout, endpoint not found, etc.).
347-
"""
343+
def wrapped_ferret_request(request_slice, https_endpoint):
348344
response = None
349345

350346
# NOTE: While we transition to HTTPS we're disabling the verify field. We
351347
# need to add a way to fetch certificates in this script ASAP.
352-
try:
353-
with warnings.catch_warnings():
354-
warnings.simplefilter("ignore")
355-
response = requests.post(https_endpoint,
356-
json=request_slice,
357-
timeout=DEFAULT_REQUEST_TIMEOUT,
358-
verify=False)
359-
360-
if not response:
361-
raise RuntimeError("No response obtained from HTTPS endpoint")
362-
363-
# If the request is unsuccessful (e.g. has a non 2xx response code),
364-
# we'll try HTTP
365-
response.raise_for_status()
366-
except Exception as e:
367-
log_info("Connect HTTPS Ferret endpoint failed (error: {}), trying HTTP...".format(e))
368-
response = requests.post(http_endpoint,
348+
with warnings.catch_warnings():
349+
warnings.simplefilter("ignore")
350+
response = requests.post(https_endpoint,
369351
json=request_slice,
370-
timeout=DEFAULT_REQUEST_TIMEOUT)
352+
timeout=DEFAULT_REQUEST_TIMEOUT,
353+
verify=False)
371354

372355
if not response:
373-
raise RuntimeError("No response obtained from HTTP endpoint")
356+
raise RuntimeError("No response obtained from HTTPS endpoint")
374357

375358
# If the request is unsuccessful (e.g. has a non 2xx response code),
376359
# we'll consider it failed
@@ -384,12 +367,11 @@ def post_neighbor_advertiser_slice(ferret_service_vip):
384367
save_as_json(request_slice, NEIGHBOR_ADVERTISER_REQUEST_SLICE_PATH)
385368

386369
https_endpoint = "https://{}:448{}{}".format(ferret_service_vip, FERRET_NEIGHBOR_ADVERTISER_API_PREFIX, get_switch_name())
387-
http_endpoint = "http://{}:85{}{}".format(ferret_service_vip, FERRET_NEIGHBOR_ADVERTISER_API_PREFIX, get_switch_name())
388370
response = None
389371

390372
for retry in range(DEFAULT_FERRET_QUERY_RETRIES):
391373
try:
392-
response = wrapped_ferret_request(request_slice, https_endpoint, http_endpoint)
374+
response = wrapped_ferret_request(request_slice, https_endpoint)
393375
except Exception as e:
394376
log_error("The request failed, vip: {}, error: {}".format(ferret_service_vip, e))
395377
return None

0 commit comments

Comments
 (0)