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

AlertApi.get_request_status raises HTTP 404 errors #31

Open
asqui opened this issue Nov 7, 2019 · 3 comments
Open

AlertApi.get_request_status raises HTTP 404 errors #31

asqui opened this issue Nov 7, 2019 · 3 comments
Assignees

Comments

@asqui
Copy link

asqui commented Nov 7, 2019

Calling AlertApi.get_request_status() immediately after create_alert() sometimes results in an ApiException with status == 404 being raised by get_request_status().

I believe the reason for this is that the alerts/requests/{id} REST endpoint may return a HTTP 404 status if the request has not started processing yet. This behaviour is not detailed in the Get Request Status documentation and is also quite counter-intuitive for a user of the SDK (or any other direct or indirect user of the REST API).

This was previously raised with Opsgenie support as internal ticket ALX-612 and I understand that this has been "resolved" by adding to the 404 response a header that indicates the request has not been processed yet. (I'm not sure why this path was chosen, rather than returning a normal 200 response for an outstanding request). This header is also not documented anywhere that I can see, and is not much help because every consumer of this REST endpoint (including all your language-specific SDKs) needs to keep this edge-case in mind and handle it appropriately!

In the case of the Python SDK, the only solution I can see is putting a retry loop to retry on HTTP 404s around any call to AlertApi.get_request_status() or SuccessResponse.retrieve_result() (or SuccessResponse.retrieve_resulting_action()... or access to the SuccessResponse..id property...) which seems rather cumbersome and unintuitive...

@mhamzak008 mhamzak008 self-assigned this Dec 10, 2019
@mhamzak008
Copy link
Contributor

I don't think that you need to put a retry loop around calls to SuccessResponse.retrieve_result() or SuccessResponse.retrieve_resulting_action() or while accessing the SuccessResponse..id property because they internally have a retry mechanism which retries until either a success response is returned or the Configuration.short_polling_max_retries is reached

@asqui
Copy link
Author

asqui commented Dec 12, 2019

So:

  • 404 errors will get retried even though they are not in the default set of retry_http_response error codes, and
  • if there was ever a bug in the API causing it to hit an invalid URL, the resultant 404 error would get retried for the maximum retry duration before failing.

Is my understanding correct?

@mhamzak008
Copy link
Contributor

Yes, that's correct. We changed it to this implementation in #16 from the one where it was retrying for only some specific scenarios. And now, I am questioning the decision back then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants