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

Waiter throw ClientError for unexpected error response #957

Merged
merged 1 commit into from
Aug 31, 2016

Conversation

ushatil
Copy link
Contributor

@ushatil ushatil commented Jun 21, 2016

Waiter should throw ClientError for unexpected error response

Problem

During a waiters wait() routine, if the botocore client throws a ClientError, and there is no Acceptor in the JSON configured to handle that specific ClientError response, then a less informative WaiterError is thrown.

In doing so, error response information is lost (such as the Error Code), making it impossible to accurately detect certain errors (namely, 5xx errors and ThrottlingException, per http://docs.aws.amazon.com/general/latest/gr/api-retries.html

This "WaiterError" is caused by a regular ClientError, and has no specific connection to Waiter logic, other than it happened during waiting (unlike other WaiterErrors, which are for waiter-specific failure conditions like "max retries exceeded")

Solution

If a ClientError occurs, and there is no Waiter logic ("acceptors") that handles it, then propagate a ClientError with all of the original information

BTW...

tests/unit/test_waters.TestWaitersObjects.test_unspecified_errors_propagate_error_code does not actually test that unspecified errors propogate the Error Code; it tests that they propogate the Error Message (won't matter if this change gets submitted)

If this change is rejected, please consider actually including the Error Code somewhere in WaiterError. Maybe also the HTTP Response Code?

@codecov-io
Copy link

Current coverage is 97.31%

Merging #957 into develop will not change coverage

@@            develop       #957   diff @@
==========================================
  Files            43         43          
  Lines          7014       7014          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits           6826       6826          
  Misses          188        188          
  Partials          0          0          

Powered by Codecov. Last updated by ab22547...cb8e16f

@JordonPhillips
Copy link
Contributor

Changing the waiter class would constitute a breaking change. I think it would be better if the error response was added as a property of the WaiterError.

@JordonPhillips JordonPhillips added incorporating-feedback pr/needs-review This PR needs a review from a member of the team. labels Jun 29, 2016
@ushatil
Copy link
Contributor Author

ushatil commented Jul 8, 2016

Agreed. I think I have a good solution; will update shortly

@jamesls
Copy link
Member

jamesls commented Aug 29, 2016

Here's what I propose:

  • Continue raising WaiterError to keep backwards compatibility
  • Add a last_response attribute on a waiter error that contains the last response we received before raising a WaiterError

The rationale behind just adding a last_response instead of exposing some sort of error_code and error_message is that a WaiterError can also be thrown in non-error states (transitioning to a failure state, hitting max-attempts), and while we can always guarantee a last response, we can't necessarily guarantee that response is a "error" response.

ec2 = s.create_client('ec2')
w = ec2.get_waiter('instance_running')
try:
    w.wait(InstanceIds=['i-1234'])
except WaiterError as e:
    if 'Error' in e.last_response:
        print "Received an error:", e.last_response['Error']['Code']

jamesls added a commit to jamesls/botocore that referenced this pull request Aug 29, 2016
The rationale behind just adding a last_response instead of exposing some sort
of error_code and error_message is that a WaiterError can also be thrown in
non-error states (transitioning to a failure state, hitting max-attempts), and
while we can always guarantee a last response, we can't necessarily guarantee
that response is a "error" response.

Closes boto#957
@jamesls jamesls merged commit cb8e16f into boto:develop Aug 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incorporating-feedback pr/needs-review This PR needs a review from a member of the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants