-
Notifications
You must be signed in to change notification settings - Fork 41
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 for async deletion of non-existent resource #3980
base: master
Are you sure you want to change the base?
Conversation
Does the PR have any schema changes?Looking good! No breaking changes found. |
// Some APIs are explicitly marked `x-ms-long-running-operation` and we should only do the | ||
// poll for the deletion result in that case. | ||
if asyncStyle != "" { | ||
pt, err := runtime.NewPoller[any](resp, c.pipeline, nil) |
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.
@thomas11 , I notice that normalizeLocationHeader
isn't being called here, as is in putOrPatch
.
Given this discussion, it probably doesn't matter, but I bring it up in case you'd like me to act on that.
if err, ok := err.(*azcore.ResponseError); ok { | ||
return nil, created, newResponseError(err.RawResponse) | ||
} |
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.
This fix is actually a follow-up to #3783. I think it is justifiably in here because the Delete call is being similarly fixed here.
@@ -418,7 +429,7 @@ func TestErrorStatusCodes(t *testing.T) { | |||
{ | |||
StatusCode: 503, // temporary failure | |||
Header: http.Header{"Location": []string{"https://management.azure.com/operation"}}, | |||
Body: io.NopCloser(strings.NewReader(`{"status": "Unavailable"}`)), |
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.
When we fake an error response, it is good to use the error schema because you can make assertions about the final error code.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3980 +/- ##
=======================================
Coverage 57.49% 57.49%
=======================================
Files 82 82
Lines 13078 13077 -1
=======================================
Hits 7519 7519
+ Misses 4984 4983 -1
Partials 575 575 ☔ View full report in Codecov by Sentry. |
This PR fixes an error that occurs in the deletion of a (non-existent) Azure resource. The issue impacts resources that have an async-style DELETE call (as is the case for Subnet, see schema).
The user-facing error is:
The call to
runtime.NewPoller
should not be made with a failed response, otherwise we hit a precondition within it:To fix, I encapsulated the request-to-final-response logic into an anonymous function, to be able to uniformly check for the 404 result. And I ensure that the initial response was successful before making a poller.
This PR relaxes the logic for detecting a 404 during resource deletion, to not care about the specific error code. I find that at least two codes are possible:
ResourceNotFound
andResourceGroupNotFound
. Note that the sync path did not check the error code.TODO:
Closes #3978
See also: #3783