Fix for async deletion of non-existent resource#3980
Conversation
Does the PR have any schema changes?Looking good! No breaking changes found. |
| if err, ok := err.(*azcore.ResponseError); ok { | ||
| return nil, created, newResponseError(err.RawResponse) | ||
| } |
There was a problem hiding this comment.
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.
| { | ||
| 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.
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.47% -0.03%
==========================================
Files 82 82
Lines 13078 13081 +3
==========================================
- Hits 7519 7518 -1
- Misses 4984 4987 +3
- Partials 575 576 +1 ☔ View full report in Codecov by Sentry. |
| if err, ok := err.(*azcore.ResponseError); ok { | ||
| return nil, created, newResponseError(err.RawResponse) | ||
| } |
8ef8cbc to
9e32b3c
Compare
9e32b3c to
4fd3fc6
Compare
|
This PR has been shipped in release v2.89.0. |
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 technical detail is that the 404 may come in the initial response as opposed to during polling, and that wasn't handled correctly..
The user-facing error is:
The call to
runtime.NewPollershould 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:
ResourceNotFoundandResourceGroupNotFound. Note that the sync path did not check the error code anyway and a uniform solution is desirable.TODO:
Closes #3978
See also: #3783