-
Notifications
You must be signed in to change notification settings - Fork 15
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
Fix: do not retry for 4xx errors #950
Conversation
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.
Can we add a test for this please?
I have checked... right now there are no tests for the provider http client. There are these tests: client/http/client_test.go - but they don't really test the provider client... (which is created in providor.go). I guess the question is: what are we trying to test? we could test this specific function, by passing responses with different status codes:
move this code to a dedicated, function... then write unit tests that each test case passes a different response object to this function. Let me know if it's something you would like to me to do. |
Didn't we add this to make the integration tests more stable? |
We did... |
I removed the line that would retry for any error... and kept the one that retries only on specific use-cases. |
no that's ok. @RLRabinowitz I'm good with this PR but I saw you also commented, so please approve if you are fine with the response. |
Well, we want to make sure that we are not retrying any 4xx HTTP errors, right? Make sure the scenario mentioned in the issue will not happen again. Adding a UT on the retry condition doesn't really help, as the fix was unrelated to that code. Ideally we'd have a test that actually makes sure that this doesn't happen again, as right now we have no guardrails saving us from this happening again Couldn't such a test simply be added to |
Ok sure. |
|
||
return func(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) { | ||
restyClient := resty.New() | ||
func createRestyClient(ctx context.Context) *resty.Client { |
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.
moved it to a function - this allows me to test almost the exact same resty.client that will be used in the provider.
@RLRabinowitz I have added unit tests as requested. |
Issue & Steps to Reproduce / Feature Request
fixes #949
Solution
Removed the default error handler.