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

tailscale: update state after modification functions for resources #362

Merged
merged 1 commit into from
May 3, 2024

Conversation

mpminardi
Copy link
Contributor

@mpminardi mpminardi commented May 1, 2024

Add calls to appropriate Read functions at the end of Create and Update functions to follow recommended best practices from HashiCorp. This is done to prevent scenarios where Terraform could otherwise have stale state after resource creation or update (from default or computed values being populated server side on the object as an example) which can result in unexpected drift in subsequent plan / apply operations.

Fixes https://github.com/tailscale/corp/issues/19698

@mpminardi mpminardi self-assigned this May 1, 2024
Add calls to appropriate `Read` functions at the end of `Create` and
`Update` functions to follow recommended best practices from HashiCorp.
This is done to prevent scenarios where Terraform could otherwise have
stale state after resource creation or update (from default or computed
values being populated server side on the object as an example) which
can result in unexpected drift in subsequent plan / apply operations.

Fixes tailscale/corp#19698

Signed-off-by: Mario Minardi <mario@tailscale.com>
@mpminardi mpminardi force-pushed the mpminardi/update-state-after-modification branch from 237ac26 to b22944a Compare May 1, 2024 19:50
@@ -67,6 +67,9 @@ func testTailnetKeyStruct(reusable bool) tailscale.Key {

func setKeyStep(reusable bool, recreateIfInvalid string) resource.TestStep {
return resource.TestStep{
PreConfig: func() {
testServer.ResponseBody = testTailnetKeyStruct(reusable)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change just makes sure the server is ready to respond with the expected data immediately since we now do a Read after the Create.

@mpminardi mpminardi marked this pull request as ready for review May 1, 2024 20:46
@mpminardi mpminardi merged commit 7087082 into main May 3, 2024
3 checks passed
@mpminardi mpminardi deleted the mpminardi/update-state-after-modification branch May 3, 2024 05:53
mpminardi added a commit that referenced this pull request May 3, 2024
Adds calls to `Read` after doing `Create` or `Update` operations for the
ACL resource. This resource was missed in #362 where it was added for
other existing resources.

Signed-off-by: Mario Minardi <mario@tailscale.com>
mpminardi added a commit that referenced this pull request May 3, 2024
Adds calls to `Read` after doing `Create` or `Update` operations for the
ACL resource. This resource was missed in #362 where it was added for
other existing resources.

Fixes tailscale/corp#19698

Signed-off-by: Mario Minardi <mario@tailscale.com>
mpminardi added a commit that referenced this pull request May 6, 2024
Adds calls to `Read` after doing `Create` or `Update` operations for the
ACL resource. This resource was missed in #362 where it was added for
other existing resources.

Fixes tailscale/corp#19698

Signed-off-by: Mario Minardi <mario@tailscale.com>
mpminardi added a commit that referenced this pull request May 6, 2024
Adds calls to `Read` after doing `Create` or `Update` operations for the
ACL resource. This resource was missed in #362 where it was added for
other existing resources.

Fixes tailscale/corp#19698

Signed-off-by: Mario Minardi <mario@tailscale.com>
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.

None yet

2 participants