cloudidentity: fix post-test destruction errors for Group and GroupMembership - #18792
cloudidentity: fix post-test destruction errors for Group and GroupMembership#18792SirGitsalot wants to merge 3 commits into
Conversation
|
Hi there, I'm the Modular magician. I've detected the following information about your changes for commit 4911c70: Diff reportYour PR generated the following diffs in downstream repositories:
Errors
Step 1: Replaying Mode Caution Build Failure during VCR tests 🔴 REPLAYING mode: The following packages failed to build:
Please fix the compilation errors to complete your PR. View the build log @SirGitsalot VCR tests complete for 4911c70! |
| @@ -0,0 +1,46 @@ | |||
| if d.Get("deletion_policy").(string) == "PREVENT" { | |||
There was a problem hiding this comment.
In mmv1/templates/terraform/resource.go.tmpl (lines 1294–1310), deletion_policy checks, config := meta.(*transport_tpg.Config), and userAgent, err := tpgresource.GenerateUserAgentString(...) are already rendered immediately before custom_delete is inserted.
Including lines 1–12 here causes config, userAgent, and err to be redeclared with := in the generated Go resource delete method, resulting in downstream provider compilation errors (config redeclared in this block, userAgent redeclared in this block, err redeclared in this block).
Please remove the preamble and start directly from billingProject := "":
| if d.Get("deletion_policy").(string) == "PREVENT" { | |
| billingProject := "" | |
| url, err := tpgresource.ReplaceVars(d, config, transport_tpg.BaseUrl(Product, config)+"{{ "{{" }}name{{ "}}" }}") | |
| if err != nil { | |
| return err | |
| } | |
| var obj map[string]interface{} | |
| // err == nil indicates that the billing_project value was found | |
| if bp, err := tpgresource.GetBillingProject(d, config); err == nil { | |
| billingProject = bp | |
| } | |
| headers := make(http.Header) | |
| log.Printf("[DEBUG] Deleting GroupMembership %q", d.Id()) | |
| res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ | |
| Config: config, | |
| Method: "DELETE", | |
| Project: billingProject, | |
| RawURL: url, | |
| UserAgent: userAgent, | |
| Body: obj, | |
| Timeout: d.Timeout(schema.TimeoutDelete), | |
| Headers: headers, | |
| }) | |
| if err != nil { | |
| return transport_tpg.HandleNotFoundError(transformCloudIdentityGroupMembershipReadError(err), d, "GroupMembership") | |
| } | |
| log.Printf("[DEBUG] Finished deleting GroupMembership %q: %#v", d.Id(), res) | |
| return nil |
4911c70 to
93dea1d
Compare
|
Hi there, I'm the Modular magician. I've detected the following information about your changes for commit 93dea1d: Diff reportYour PR generated the following diffs in downstream repositories:
Test reportAnalytics
Affected Service Packages
Step 1: Replaying Mode Action takenFound 10 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
View the replaying VCR build log Step 2: Recording Mode
Caution Issues requiring attention before PR completion 🔴 Initial Recording Failed: Some tests failed during the recording step. See the table above for details. Please address these issues to complete your PR. If you believe these detections are incorrect or unrelated to your change, please raise the concern with your reviewer. View the recording VCR build log or the debug logs folder for detailed results. @SirGitsalot VCR tests complete for 93dea1d! |
And fixed borked suggestion
|
Hi there, I'm the Modular magician. I've detected the following information about your changes for commit f6d2653: Diff reportYour PR generated the following diffs in downstream repositories:
Errors
Test reportAnalytics
Affected Service Packages
Step 1: Replaying Mode Action takenFound 12 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
View the replaying VCR build log Step 2: Recording Mode
Caution Issues requiring attention before PR completion 🔴 Initial Recording Failed: Some tests failed during the recording step. See the table above for details. Please address these issues to complete your PR. If you believe these detections are incorrect or unrelated to your change, please raise the concern with your reviewer. View the recording VCR build log or the debug logs folder for detailed results. @SirGitsalot VCR tests complete for f6d2653! |
|
Hi there, I'm the Modular magician. I've detected the following information about your changes for commit f36f620: Diff reportYour PR generated the following diffs in downstream repositories:
Test reportAnalytics
Affected Service Packages
Step 1: Replaying Mode Action takenFound 13 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
View the replaying VCR build log Step 2: Recording Mode
Caution Issues requiring attention before PR completion 🔴 Initial Recording Failed: Some tests failed during the recording step. See the table above for details. Please address these issues to complete your PR. If you believe these detections are incorrect or unrelated to your change, please raise the concern with your reviewer. View the recording VCR build log or the debug logs folder for detailed results. @SirGitsalot VCR tests complete for f36f620! |
|
@modular-magician reassign-reviewer |
Fixes nightly acceptance test failures for Cloud Identity Group test cases:
TestAccCloudIdentityGroup/updateTestAccCloudIdentityGroup/membership_dneRoot Cause & Fix
Cloud Identity Group Membership 403 on Deletion/Teardown:
When deleting a
google_cloud_identity_group_membershipthat no longer exists (e.g. during post-test destroy or cleanup), Cloud Identity returnsgoogleapi: Error 403: Error(2028): Permission denied for resource ... (or it may not exist).Because Terraform standard deletion expects a 404 for nonexistent resources, the 403 error caused destroy operations to fail.
This change adds a
custom_deletetemplate inmmv1/templates/terraform/custom_delete/cloud_identity_group_membership.go.tmplthat applies the existingtransformCloudIdentityGroupMembershipReadErrorhelper during deletion, properly converting the ambiguous 403 to a 404 soHandleNotFoundErrortreats the resource as removed.Cloud Identity Group 409 Aborted on Deletion:
When deleting a
google_cloud_identity_group, concurrent updates or backend state transitions can cause the API to returngoogleapi: Error 409: The operation was aborted.before async polling begins.This change introduces
IsCloudIdentityGroup409inmmv1/third_party/terraform/transport/error_retry_predicates.goand attaches it toerror_retry_predicatesinmmv1/products/cloudidentity/Group.yamlto retry transient 409 abort errors during deletion.