Skip to content

Handle TF drift more gracefully for ti_resource_group and ti_resource_group_assignment #5

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

Merged
merged 2 commits into from
Jul 23, 2024

Conversation

otherchen
Copy link
Collaborator

This article provides a good initial explanation of the expected behaviors of the different CRUD methods for a resource.

In it, it mentions that the Read method should be able to gracefully handle when the resource no longer exists (probably due to manual deletion).

I also fixed a bug where resourceGroup was supposed to be resource_group and also modified petoju --> zph in certain places. This makes error logs a bit more clear.

@@ -188,7 +191,7 @@ func DeleteResourceGroup(ctx context.Context, d *schema.ResourceData, meta inter
if err != nil {
return diag.FromErr(err)
}
// TODO: check for users assigned as safety? and assert zero?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This already happens at the TiDB layer - it doesn't let you delete a resource group if it is still assigned to a user.

d.Set("user", user)
d.Set("resourceGroup", resourceGroup)
d.Set("resource_group", resourceGroup)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was resulting in weird tf diffs - fixing so that we see the correct rg state!

@zph zph merged commit cc4f335 into r3.0.62 Jul 23, 2024
@zph zph deleted the ac-resource-controls-graceful-diff-v2 branch July 23, 2024 21:01
@zph zph restored the ac-resource-controls-graceful-diff-v2 branch July 23, 2024 21:01
@zph zph deleted the ac-resource-controls-graceful-diff-v2 branch July 23, 2024 21:01
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