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
fix: Handles resource deletion in ReadResource #2268
Conversation
This PR has gone 7 days without any activity and meets the project’s definition of "stale". This will be auto-closed if there is no new activity over the next 7 days. If the issue is still relevant and active, you can simply comment with a "bump" to keep it open, or add the label "not_stale". Thanks for keeping our repository healthy! |
APIx bot: a message has been sent to Docs Slack channel |
@@ -289,8 +289,12 @@ func (r *encryptionAtRestRS) Read(ctx context.Context, req resource.ReadRequest, | |||
|
|||
connV2 := r.Client.AtlasV2 | |||
|
|||
encryptionResp, _, err := connV2.EncryptionAtRestUsingCustomerKeyManagementApi.GetEncryptionAtRest(context.Background(), projectID).Execute() | |||
encryptionResp, getResp, err := connV2.EncryptionAtRestUsingCustomerKeyManagementApi.GetEncryptionAtRest(context.Background(), projectID).Execute() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
encryptionResp, getResp, err := connV2.EncryptionAtRestUsingCustomerKeyManagementApi.GetEncryptionAtRest(context.Background(), projectID).Execute() | |
encryptionResp, resp, err := connV2.EncryptionAtRestUsingCustomerKeyManagementApi.GetEncryptionAtRest(context.Background(), projectID).Execute() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resp
is already defined in the method signature:
func (r *encryptionAtRestRS) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
if err != nil { | ||
if resp != nil && resp.StatusCode == http.StatusNotFound { | ||
d.SetId("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why in here we don't do resp.State.RemoveResource(ctx)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same question, what is it for and why we use it only in some resources. do we also need to call d.SetId("") when calling RemoveResource?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the difference between SDK v2 and TPF in how we mark a resource as deleted, see google doc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for your patience :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 non-blocking suggestion. LGTM.
@@ -0,0 +1,23 @@ | |||
```release-note:bug | |||
resource/cloud_backup_schedule: Fixes behavior when resource is deleted outside of Terraform. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AgustinBettati should changelog sentences end in period? I see most of them don't have it, but some of them have it like https://github.com/mongodb/terraform-provider-mongodbatlas/blob/master/.changelog/2208.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking at: https://github.com/mongodb/terraform-provider-mongodbatlas/blob/master/CHANGELOG.md
it looks like it would be better NOT to have periods at the end, as the after the sentence it's the associated PR link
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@EspenAlbert apart from removing periods note that resources should have mongodbatlas_ as prefix, e.g.: resource/mongodbatlas_cloud_backup_schedule: ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to refresh the PR 🤦, and merged this. I'll create a follow up PR to remove the trailing dot and ensure the prefix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lantoli and @AgustinBettati updated in follow-up PR: #2298
Only |
Description
Handles resource deletion in ReadResource.
Terraform informs you about the resource deleted outside of Terraform, and the plan will re-create the resource
Link to any related issue(s): CLOUDP-248670
Type of change:
Required Checklist:
Further comments