From d1004c2cb739539a9e518903bebf64f49424d870 Mon Sep 17 00:00:00 2001 From: Zhenhua Li Date: Tue, 19 Sep 2023 13:51:26 -0700 Subject: [PATCH] Catch the error when deleteConnection fails --- .../resource_service_networking_connection.go | 39 +------------------ 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/mmv1/third_party/terraform/services/servicenetworking/resource_service_networking_connection.go b/mmv1/third_party/terraform/services/servicenetworking/resource_service_networking_connection.go index 2d098a318110..99acabd82732 100644 --- a/mmv1/third_party/terraform/services/servicenetworking/resource_service_networking_connection.go +++ b/mmv1/third_party/terraform/services/servicenetworking/resource_service_networking_connection.go @@ -8,13 +8,11 @@ import ( "strings" "time" - tpgcompute "github.com/hashicorp/terraform-provider-google/google/services/compute" "github.com/hashicorp/terraform-provider-google/google/tpgresource" transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" "github.com/hashicorp/errwrap" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "google.golang.org/api/compute/v1" "google.golang.org/api/servicenetworking/v1" ) @@ -287,41 +285,8 @@ func resourceServiceNetworkingConnectionDelete(d *schema.ResourceData, meta inte } if err := ServiceNetworkingOperationWaitTime(config, op, "Delete Service Networking Connection", userAgent, project, d.Timeout(schema.TimeoutCreate)); err != nil { - obj := make(map[string]interface{}) - peering := d.Get("peering").(string) - obj["name"] = peering - url := fmt.Sprintf("%s%s/removePeering", config.ComputeBasePath, serviceNetworkingNetworkName) - - networkFieldValue, err := tpgresource.ParseNetworkFieldValue(network, d, config) - if err != nil { - return errwrap.Wrapf("Failed to retrieve network field value, err: {{err}}", err) - } - - project := networkFieldValue.Project - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: project, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ServiceNetworkingConnection %q", d.Id())) - } - - op := &compute.Operation{} - err = tpgresource.Convert(res, op) - if err != nil { - return err - } - - err = tpgcompute.ComputeOperationWaitTime( - config, op, project, "Updating Network", userAgent, d.Timeout(schema.TimeoutDelete)) - if err != nil { - return err - } + log.Printf("[INFO] Error deleting Service Networking Connection: %s", err) + return nil } d.SetId("")