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

Retry Conflicts for AnotherOperationInProgress #3653

Merged
merged 1 commit into from
Oct 28, 2024
Merged

Conversation

danielrbradley
Copy link
Member

@danielrbradley danielrbradley commented Oct 18, 2024

The new azclient allows us to pass a callback function to decide if we want to retry a request. The default behaviour is to only retry a specific set of status codes. This extends that behaviour to also check Conflict (409) and retry if the "error.code" field is "AnotherOperationInProgress".

We're avoiding retrying all conflict status codes because some won't be fixed with a retry, so we're targeting the specific case instead.

Tested this both manually stepping through the code with a debugger and also created an integration test which previously failed but now passes when configured to use the new azclient instead of autorest client.

To access this improved behaviour right now, set the environment variable PULUMI_ENABLE_AZCORE_BACKEND=true. This will become the default in the future, but is currently in testing behind a feature flag.

This should address #903 which we will close once we've defaulted to using the new azcore implementation:

@thomas11
Copy link
Contributor

Note that the feature toggle variable has been renamed to PULUMI_ENABLE_AZCORE_BACKEND.

@danielrbradley
Copy link
Member Author

Note that the feature toggle variable has been renamed to PULUMI_ENABLE_AZCORE_BACKEND.

This code path still seems to use the variable I'm referencing:

if os.Getenv("PULUMI_USE_AUTOREST") == "false" {

Copy link

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

@thomas11
Copy link
Contributor

Note that the feature toggle variable has been renamed to PULUMI_ENABLE_AZCORE_BACKEND.

This code path still seems to use the variable I'm referencing:

if os.Getenv("PULUMI_USE_AUTOREST") == "false" {

Yes, the rename is in a PR #3630 that will be merged shortly (I hope).

Copy link

codecov bot commented Oct 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 57.43%. Comparing base (ce90e01) to head (f37c6be).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3653      +/-   ##
==========================================
- Coverage   59.07%   57.43%   -1.64%     
==========================================
  Files          70       70              
  Lines       11102    11131      +29     
==========================================
- Hits         6558     6393     -165     
- Misses       4041     4257     +216     
+ Partials      503      481      -22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@danielrbradley
Copy link
Member Author

Yes, the rename is in a PR #3630 that will be merged shortly (I hope).

Ok, happy to wait for that to go in, update this, then merge.

Copy link
Contributor

@thomas11 thomas11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the ResponseError suggestion and would try to use it. But approving since the current version also LGTM.

provider/pkg/azure/client_azcore.go Outdated Show resolved Hide resolved
The new azclient allows us to pass a callback function to decide if we want to retry a request. The default behaviour is to only retry a specific set of status codes. This extends that behaviour to also check Conflict (409) and retry if the "error.code" field is "AnotherOperationInProgress".

We're avoiding retrying all conflict status codes because some won't be fixed with a retry, so we're targeting the specific case instead.

Tested this both manually stepping through the code with a debugger and also created an integration test which previously failed but now passes when configured to use the new azclient instead of autorest client.

To access this improved behaviour right now, set the environment variable `PULUMI_USE_AUTOREST=false`. This will become the default in the future, but is currently in testing behind a feature flag.

Fixes #903

Rework to make testing easier

- Deserialize into concrete struct rather than maps to avoid possible panics.
- 100% coverage of shouldRetryConflict and makes ShouldRetry trivial - which is tested via the integration test.

Use azcore runtime.NewResponseError

- Handles XML variants of errors too.

Use PULUMI_ENABLE_AZCORE_BACKEND instead of PULUMI_USE_AUTOREST
@danielrbradley
Copy link
Member Author

Squashed, rebased and switch PULUMI_USE_AUTOREST to PULUMI_ENABLE_AZCORE_BACKEND in the test

@pulumi-bot
Copy link
Contributor

This PR has been shipped in release v2.69.0.

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

Successfully merging this pull request may close these issues.

4 participants