-
Notifications
You must be signed in to change notification settings - Fork 970
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
RANGER-3370: Python ranger_client call_api - add case for 404 response #110
Conversation
@chia7712 Can you help me with this CI error? :) |
I filed a PR (#105) to fix CI. However, I'm not Ranger committer so it needs love from other guys :) |
@mneethiraj can you take a look at this PR? |
@chia7712 thank you for your fast response, i will try to get the attention of the comitters |
@kulkabhay @coheigea @rameeshm @gautamborad @zhangqiang2 @sneethiraj |
@chia7712 my friend, do you know any body that can look at my PR? hahaha I mean, is there any active ranger committer i can call? |
Sorry that I'm newbie in ranger community :( |
@@ -324,6 +324,11 @@ def __call_api(self, api, query_params=None, request_data=None): | |||
LOG.error("Ranger admin unavailable. HTTP Status: %s", HTTPStatus.SERVICE_UNAVAILABLE) | |||
|
|||
ret = None | |||
elif response.status_code == HTTPStatus.SERVICE_NOT_FOUND: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider renaming SERVICE_NOT_FOUND => NOT_FOUND.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the comments @mneethiraj, it makes sense
@@ -324,6 +324,11 @@ def __call_api(self, api, query_params=None, request_data=None): | |||
LOG.error("Ranger admin unavailable. HTTP Status: %s", HTTPStatus.SERVICE_UNAVAILABLE) | |||
|
|||
ret = None | |||
elif response.status_code == HTTPStatus.SERVICE_NOT_FOUND: | |||
LOG.error("Ranger service not found. HTTP Status: %s", HTTPStatus.SERVICE_NOT_FOUND) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Ranger service not found" => "Not found"
@mneethiraj thank you for your comments, the changes make sense. |
@mneethiraj is everything fine? |
@mneethiraj can you please take a look? |
@alvaroqueiroz - thank you for the patch with the updates. I filed RANGER-3370, and merged this patch in master and ranger-2.2 branches. |
One exemple of problem this PR wants to solve:
When using the method ranger.get_policy(), if the policy do not exists, i get the following error:
It will crash any program.
This will happen with other methods too.
It happens because the API call do not have a case for dealing with the response 404 (resource do not exist).
So i'm adding it
After this fix, when ranger.get_policy() method is called for a policy da does not exists, it will return None