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

support partial mode to avoid writing diff to state while Update error #257

Merged
merged 2 commits into from
Feb 13, 2023

Conversation

teowa
Copy link
Contributor

@teowa teowa commented Feb 9, 2023

Update with wrong API version will write wrong value to state file, which leads to state refresh error in later apply.

related to hashicorp/terraform-plugin-sdk#476
use the partial mode, see doc:

If the Update callback returns with or without an error, the full state is saved. If the ID becomes blank, the resource is destroyed (even within an update, though this shouldn't happen except in error scenarios).

Partial mode is a mode that can be enabled by a callback that tells Terraform that it is possible for partial state to occur. When this mode is enabled, the provider must explicitly tell Terraform what is safe to persist and what is not.

TF_ACC=1 go test -v ./internal/services -parallel 20 -test.run=TestAccGenericResource_invalidVersionUpdate -timeout 1440m -ldflags="-X=github.com/Azure/terraform-provider-azapi/version.ProviderVersion=acc"
=== RUN   TestAccGenericResource_invalidVersionUpdate
=== PAUSE TestAccGenericResource_invalidVersionUpdate
=== CONT  TestAccGenericResource_invalidVersionUpdate
--- PASS: TestAccGenericResource_invalidVersionUpdate (99.38s)
PASS
ok      github.com/Azure/terraform-provider-azapi/internal/services     101.030s

@teowa
Copy link
Contributor Author

teowa commented Feb 9, 2023

@microsoft-github-policy-service agree

@teowa teowa changed the title support partial mode in update to avoid writing diff to state while error support partial mode to avoid writing diff to state while Update error Feb 13, 2023
Copy link
Member

@ms-henglu ms-henglu left a comment

Choose a reason for hiding this comment

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

Hi @teowa ,

Thank you so much for making this PR! It looks good to me, but would you please also make this change to other azapi resources? Thanks!

@teowa teowa requested a review from ms-henglu February 13, 2023 07:49
Copy link
Member

@ms-henglu ms-henglu left a comment

Choose a reason for hiding this comment

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

LGTM!

@ms-henglu ms-henglu merged commit aed6098 into Azure:main Feb 13, 2023
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.

2 participants