Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[neighbor advertiser] catch all exceptions while trying https endpoint #757

Merged
merged 2 commits into from
Dec 2, 2019

Conversation

yxieca
Copy link
Contributor

@yxieca yxieca commented Dec 1, 2019

- What I did

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]

- How to verify it
warm-reboot-control-plane-assistant test. Also tested with https endpoint success code and timeout.

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]>
@yxieca
Copy link
Contributor Author

yxieca commented Dec 2, 2019

retest this please

@@ -356,8 +355,8 @@ 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...")
except Exception as e:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trzhang-msft @yxieca is it ever possible for the HTTPS endpoint to return a response with an error code (like 401, 403, etc.)? If it is possible, do we want to fail immediately if such an error code is returned or do we want to try the HTTP endpoint?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be returning these codes. But I think we should still retry until http endpoint also failed. Bypassing http endpoint would be tossing away a chance to work. IMHO.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, that's my concern. I think if one of those error codes is returned then there won't be an exception, so this method will just return the response to the post_neighbor_advertiser_slice method. That method returns failure if the response code is not 200. So, if we think one of these error codes might be returned by the HTTPS endpoint we might want to move that error handling logic into this method so that we can retry with the HTTP endpoint if need be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean. Good catch!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daall is correct. HTTP/HTTPs status codes include non-200, like 400 for bad request. But whether non-200 is treated as an exception is fully client side logic, and I'm not sure about the python built-in behavior here.

@yxieca yxieca merged commit 4e272c3 into sonic-net:master Dec 2, 2019
@yxieca yxieca deleted the advertiser branch December 2, 2019 22:50
yxieca added a commit that referenced this pull request Dec 2, 2019
#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
abdosi pushed a commit that referenced this pull request Jan 3, 2020
#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
stepanblyschak pushed a commit to stepanblyschak/sonic-utilities that referenced this pull request Apr 28, 2022
6cfb3ecb0248768da0a91e5f7fb4477c5da7eb4e (HEAD -> 201911, origin/201911) [build]: allow to use extra inc/lib location to build the package (sonic-net#595)
40d34872d3b7f354adac67f084eebf6ee467f779 Merge pull request sonic-net#846 from xumia/azp-201911
76ac50f147a7d820b19d8d7628a67f2fe4f5159b Disable the build test
6c9cf655b8b5b152cab1d578e05eddf8238b81b0 Fix branch reference error
ca8d81d37a9b0294098f161b036d330d9ff461e0 [ci]: download artifacts from master branch (sonic-net#768)
0cbf4d55c67a9f8f52715f95536f3588acf06c4a [ci]: use sonicbld pool (sonic-net#766)
b6f1265ee9bd86f8a5e909a6f1e9b2384497c906 [ci]: add build for arm64 and armhf (sonic-net#757)
9ec0a7da64d479b124815edc5b505fb88b2532a0 CI: add azure pipeline CI/CD (sonic-net#754)
1436dbe02cd3c56f796c6b3398d4075cd05d97e0 Fix RIF issue (sonic-net#835)

Signed-off-by: Abhishek Dosi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants