From 8cbeb84dbeef45c22ae45d95f35d454419ce68a6 Mon Sep 17 00:00:00 2001 From: DCL Team Date: Wed, 18 May 2022 15:43:24 -0700 Subject: [PATCH] Automated DCL import. - 03396622cff58701f899e348430c521c199cfc6c Automatic import from cloud_mmv2_dcl_20220518_1531_RC00 by DCL Team GitOrigin-RevId: 03396622cff58701f899e348430c521c199cfc6c --- dcl/transport.go | 4 +++ .../environment_group_attachment_internal.go | 27 +++++++++---------- .../alpha/environment_group_internal.go | 27 +++++++++---------- .../apigee/alpha/environment_internal.go | 27 +++++++++---------- .../google/apigee/alpha/instance_internal.go | 27 +++++++++---------- .../apigee/alpha/organization_internal.go | 27 +++++++++---------- .../environment_group_attachment_internal.go | 27 +++++++++---------- .../apigee/beta/environment_group_internal.go | 27 +++++++++---------- .../apigee/beta/environment_internal.go | 27 +++++++++---------- .../google/apigee/beta/instance_internal.go | 27 +++++++++---------- .../apigee/beta/organization_internal.go | 27 +++++++++---------- .../environment_group_attachment_internal.go | 27 +++++++++---------- .../apigee/environment_group_internal.go | 27 +++++++++---------- .../google/apigee/environment_internal.go | 27 +++++++++---------- services/google/apigee/instance_internal.go | 27 +++++++++---------- .../google/apigee/organization_internal.go | 27 +++++++++---------- .../alpha/workload_internal.go | 27 +++++++++---------- .../beta/workload_internal.go | 27 +++++++++---------- .../assuredworkloads/workload_internal.go | 27 +++++++++---------- .../google/bigquery/alpha/dataset_internal.go | 27 +++++++++---------- .../google/bigquery/alpha/routine_internal.go | 27 +++++++++---------- .../google/bigquery/beta/dataset_internal.go | 27 +++++++++---------- .../google/bigquery/beta/routine_internal.go | 27 +++++++++---------- services/google/bigquery/dataset_internal.go | 27 +++++++++---------- services/google/bigquery/routine_internal.go | 27 +++++++++---------- .../alpha/assignment_internal.go | 27 +++++++++---------- .../alpha/capacity_commitment_internal.go | 27 +++++++++---------- .../alpha/reservation_internal.go | 27 +++++++++---------- .../assignment_internal.go | 27 +++++++++---------- .../beta/assignment_internal.go | 27 +++++++++---------- .../beta/capacity_commitment_internal.go | 27 +++++++++---------- .../beta/reservation_internal.go | 27 +++++++++---------- .../capacity_commitment_internal.go | 27 +++++++++---------- .../reservation_internal.go | 27 +++++++++---------- .../billingbudgets/alpha/budget_internal.go | 27 +++++++++---------- .../billingbudgets/beta/budget_internal.go | 27 +++++++++---------- .../google/billingbudgets/budget_internal.go | 27 +++++++++---------- .../alpha/attestor_internal.go | 27 +++++++++---------- .../binaryauthorization/attestor_internal.go | 27 +++++++++---------- .../beta/attestor_internal.go | 27 +++++++++---------- .../cloudbuild/alpha/worker_pool_internal.go | 27 +++++++++---------- .../cloudbuild/beta/worker_pool_internal.go | 27 +++++++++---------- .../google/cloudbuild/worker_pool_internal.go | 27 +++++++++---------- .../alpha/delivery_pipeline_internal.go | 27 +++++++++---------- .../clouddeploy/alpha/target_internal.go | 27 +++++++++---------- .../beta/delivery_pipeline_internal.go | 27 +++++++++---------- .../clouddeploy/beta/target_internal.go | 27 +++++++++---------- .../clouddeploy/delivery_pipeline_internal.go | 27 +++++++++---------- .../google/clouddeploy/target_internal.go | 27 +++++++++---------- .../cloudfunctions/alpha/function_internal.go | 27 +++++++++---------- .../cloudfunctions/beta/function_internal.go | 27 +++++++++---------- .../cloudfunctions/function_internal.go | 27 +++++++++---------- .../cloudidentity/alpha/group_internal.go | 27 +++++++++---------- .../alpha/membership_internal.go | 27 +++++++++---------- .../cloudidentity/beta/group_internal.go | 27 +++++++++---------- .../cloudidentity/beta/membership_internal.go | 27 +++++++++---------- .../google/cloudidentity/group_internal.go | 27 +++++++++---------- .../cloudidentity/membership_internal.go | 27 +++++++++---------- .../alpha/tag_key_internal.go | 27 +++++++++---------- .../beta/tag_key_internal.go | 27 +++++++++---------- .../cloudresourcemanager/tag_key_internal.go | 27 +++++++++---------- .../cloudscheduler/alpha/job_internal.go | 27 +++++++++---------- .../cloudscheduler/beta/job_internal.go | 27 +++++++++---------- .../google/cloudscheduler/job_internal.go | 27 +++++++++---------- .../compute/alpha/forwarding_rule_internal.go | 27 +++++++++---------- .../alpha/instance_group_manager_internal.go | 27 +++++++++---------- .../google/compute/alpha/instance_internal.go | 27 +++++++++---------- .../alpha/interconnect_attachment_internal.go | 27 +++++++++---------- .../google/compute/alpha/network_internal.go | 27 +++++++++---------- .../alpha/packet_mirroring_internal.go | 27 +++++++++---------- .../google/compute/alpha/route_internal.go | 27 +++++++++---------- .../alpha/service_attachment_internal.go | 27 +++++++++---------- .../compute/alpha/subnetwork_internal.go | 27 +++++++++---------- .../compute/alpha/vpn_tunnel_internal.go | 27 +++++++++---------- .../compute/beta/forwarding_rule_internal.go | 27 +++++++++---------- .../beta/instance_group_manager_internal.go | 27 +++++++++---------- .../google/compute/beta/instance_internal.go | 27 +++++++++---------- .../beta/interconnect_attachment_internal.go | 27 +++++++++---------- .../google/compute/beta/network_internal.go | 27 +++++++++---------- .../compute/beta/packet_mirroring_internal.go | 27 +++++++++---------- .../google/compute/beta/route_internal.go | 27 +++++++++---------- .../beta/service_attachment_internal.go | 27 +++++++++---------- .../compute/beta/subnetwork_internal.go | 27 +++++++++---------- .../compute/beta/vpn_tunnel_internal.go | 27 +++++++++---------- .../compute/forwarding_rule_internal.go | 27 +++++++++---------- .../instance_group_manager_internal.go | 27 +++++++++---------- services/google/compute/instance_internal.go | 27 +++++++++---------- .../interconnect_attachment_internal.go | 27 +++++++++---------- services/google/compute/network_internal.go | 27 +++++++++---------- .../compute/packet_mirroring_internal.go | 27 +++++++++---------- services/google/compute/route_internal.go | 27 +++++++++---------- .../compute/service_attachment_internal.go | 27 +++++++++---------- .../google/compute/subnetwork_internal.go | 27 +++++++++---------- .../google/compute/vpn_tunnel_internal.go | 27 +++++++++---------- .../alpha/instance_internal.go | 27 +++++++++---------- .../containeranalysis/alpha/note_internal.go | 27 +++++++++---------- .../containeranalysis/beta/note_internal.go | 27 +++++++++---------- .../google/containeranalysis/note_internal.go | 27 +++++++++---------- .../containeraws/alpha/cluster_internal.go | 27 +++++++++---------- .../containeraws/alpha/node_pool_internal.go | 27 +++++++++---------- .../containeraws/beta/cluster_internal.go | 27 +++++++++---------- .../containeraws/beta/node_pool_internal.go | 27 +++++++++---------- .../google/containeraws/cluster_internal.go | 27 +++++++++---------- .../google/containeraws/node_pool_internal.go | 27 +++++++++---------- .../alpha/azure_client_internal.go | 27 +++++++++---------- .../containerazure/alpha/cluster_internal.go | 27 +++++++++---------- .../alpha/node_pool_internal.go | 27 +++++++++---------- .../containerazure/azure_client_internal.go | 27 +++++++++---------- .../beta/azure_client_internal.go | 27 +++++++++---------- .../containerazure/beta/cluster_internal.go | 27 +++++++++---------- .../containerazure/beta/node_pool_internal.go | 27 +++++++++---------- .../google/containerazure/cluster_internal.go | 27 +++++++++---------- .../containerazure/node_pool_internal.go | 27 +++++++++---------- .../datafusion/alpha/instance_internal.go | 27 +++++++++---------- .../datafusion/beta/instance_internal.go | 27 +++++++++---------- .../google/dataplex/alpha/asset_internal.go | 27 +++++++++---------- .../google/dataplex/alpha/lake_internal.go | 27 +++++++++---------- .../google/dataplex/alpha/zone_internal.go | 27 +++++++++---------- services/google/dataplex/asset_internal.go | 27 +++++++++---------- .../google/dataplex/beta/asset_internal.go | 27 +++++++++---------- .../google/dataplex/beta/lake_internal.go | 27 +++++++++---------- .../google/dataplex/beta/zone_internal.go | 27 +++++++++---------- services/google/dataplex/lake_internal.go | 27 +++++++++---------- services/google/dataplex/zone_internal.go | 27 +++++++++---------- .../alpha/autoscaling_policy_internal.go | 27 +++++++++---------- .../google/dataproc/alpha/cluster_internal.go | 27 +++++++++---------- .../alpha/workflow_template_internal.go | 27 +++++++++---------- .../dataproc/autoscaling_policy_internal.go | 27 +++++++++---------- .../beta/autoscaling_policy_internal.go | 27 +++++++++---------- .../google/dataproc/beta/cluster_internal.go | 27 +++++++++---------- .../beta/workflow_template_internal.go | 27 +++++++++---------- services/google/dataproc/cluster_internal.go | 27 +++++++++---------- .../dataproc/workflow_template_internal.go | 27 +++++++++---------- .../dlp/alpha/inspect_template_internal.go | 27 +++++++++---------- .../google/dlp/alpha/job_trigger_internal.go | 20 ++++++++++---- .../dlp/alpha/stored_info_type_internal.go | 12 ++++++--- .../dlp/beta/inspect_template_internal.go | 27 +++++++++---------- .../google/dlp/beta/job_trigger_internal.go | 20 ++++++++++---- .../dlp/beta/stored_info_type_internal.go | 12 ++++++--- .../google/dlp/inspect_template_internal.go | 27 +++++++++---------- services/google/dlp/job_trigger_internal.go | 20 ++++++++++---- .../google/dlp/stored_info_type_internal.go | 12 ++++++--- .../google/eventarc/alpha/trigger_internal.go | 27 +++++++++---------- .../google/eventarc/beta/trigger_internal.go | 27 +++++++++---------- services/google/eventarc/trigger_internal.go | 27 +++++++++---------- .../google/filestore/alpha/backup_internal.go | 27 +++++++++---------- .../filestore/alpha/instance_internal.go | 27 +++++++++---------- .../google/filestore/beta/backup_internal.go | 27 +++++++++---------- .../filestore/beta/instance_internal.go | 27 +++++++++---------- .../google/filestore/instance_internal.go | 27 +++++++++---------- .../gameservices/alpha/realm_internal.go | 27 +++++++++---------- .../gameservices/beta/realm_internal.go | 27 +++++++++---------- .../google/gameservices/realm_internal.go | 27 +++++++++---------- .../google/gkehub/alpha/feature_internal.go | 27 +++++++++---------- .../gkehub/alpha/membership_internal.go | 27 +++++++++---------- .../google/gkehub/beta/feature_internal.go | 27 +++++++++---------- .../google/gkehub/beta/membership_internal.go | 27 +++++++++---------- .../iam/alpha/service_account_internal.go | 26 +++++++++--------- .../iam/beta/service_account_internal.go | 26 +++++++++--------- .../google/iam/service_account_internal.go | 26 +++++++++--------- .../identity_aware_proxy_client_internal.go | 27 +++++++++---------- .../identity_aware_proxy_client_internal.go | 27 +++++++++---------- .../identity_aware_proxy_client_internal.go | 27 +++++++++---------- .../alpha/oauth_idp_config_internal.go | 27 +++++++++---------- .../identitytoolkit/alpha/tenant_internal.go | 27 +++++++++---------- .../alpha/tenant_oauth_idp_config_internal.go | 27 +++++++++---------- .../beta/oauth_idp_config_internal.go | 27 +++++++++---------- .../identitytoolkit/beta/tenant_internal.go | 27 +++++++++---------- .../beta/tenant_oauth_idp_config_internal.go | 27 +++++++++---------- .../oauth_idp_config_internal.go | 27 +++++++++---------- .../google/identitytoolkit/tenant_internal.go | 27 +++++++++---------- .../tenant_oauth_idp_config_internal.go | 27 +++++++++---------- .../logging/alpha/log_exclusion_internal.go | 27 +++++++++---------- .../logging/alpha/log_metric_internal.go | 27 +++++++++---------- .../google/logging/alpha/log_view_internal.go | 27 +++++++++---------- .../logging/beta/log_exclusion_internal.go | 27 +++++++++---------- .../logging/beta/log_metric_internal.go | 27 +++++++++---------- .../google/logging/beta/log_view_internal.go | 27 +++++++++---------- .../google/logging/log_exclusion_internal.go | 27 +++++++++---------- .../google/logging/log_metric_internal.go | 27 +++++++++---------- services/google/logging/log_view_internal.go | 27 +++++++++---------- .../monitoring/alpha/dashboard_internal.go | 27 +++++++++---------- .../google/monitoring/alpha/group_internal.go | 27 +++++++++---------- .../alpha/metric_descriptor_internal.go | 26 +++++++++--------- .../alpha/monitored_project_internal.go | 27 +++++++++---------- .../alpha/notification_channel_internal.go | 27 +++++++++---------- .../alpha/uptime_check_config_internal.go | 27 +++++++++---------- .../monitoring/beta/dashboard_internal.go | 27 +++++++++---------- .../google/monitoring/beta/group_internal.go | 27 +++++++++---------- .../beta/metric_descriptor_internal.go | 26 +++++++++--------- .../beta/monitored_project_internal.go | 27 +++++++++---------- .../beta/notification_channel_internal.go | 27 +++++++++---------- .../beta/uptime_check_config_internal.go | 27 +++++++++---------- .../google/monitoring/dashboard_internal.go | 27 +++++++++---------- services/google/monitoring/group_internal.go | 27 +++++++++---------- .../monitoring/metric_descriptor_internal.go | 26 +++++++++--------- .../monitoring/monitored_project_internal.go | 27 +++++++++---------- .../notification_channel_internal.go | 27 +++++++++---------- .../uptime_check_config_internal.go | 27 +++++++++---------- .../networkconnectivity/alpha/hub_internal.go | 27 +++++++++---------- .../alpha/spoke_internal.go | 27 +++++++++---------- .../networkconnectivity/beta/hub_internal.go | 27 +++++++++---------- .../beta/spoke_internal.go | 27 +++++++++---------- .../networkconnectivity/hub_internal.go | 27 +++++++++---------- .../networkconnectivity/spoke_internal.go | 27 +++++++++---------- .../alpha/authorization_policy_internal.go | 27 +++++++++---------- .../alpha/client_tls_policy_internal.go | 27 +++++++++---------- .../alpha/server_tls_policy_internal.go | 27 +++++++++---------- .../beta/authorization_policy_internal.go | 27 +++++++++---------- .../beta/client_tls_policy_internal.go | 27 +++++++++---------- .../beta/server_tls_policy_internal.go | 27 +++++++++---------- .../alpha/endpoint_policy_internal.go | 27 +++++++++---------- .../networkservices/alpha/gateway_internal.go | 27 +++++++++---------- .../alpha/grpc_route_internal.go | 27 +++++++++---------- .../alpha/http_filter_internal.go | 27 +++++++++---------- .../alpha/http_route_internal.go | 27 +++++++++---------- .../networkservices/alpha/mesh_internal.go | 27 +++++++++---------- .../alpha/service_binding_internal.go | 27 +++++++++---------- .../alpha/tcp_route_internal.go | 27 +++++++++---------- .../alpha/tls_route_internal.go | 27 +++++++++---------- .../beta/endpoint_policy_internal.go | 27 +++++++++---------- .../networkservices/beta/gateway_internal.go | 27 +++++++++---------- .../beta/grpc_route_internal.go | 27 +++++++++---------- .../beta/http_route_internal.go | 27 +++++++++---------- .../networkservices/beta/mesh_internal.go | 27 +++++++++---------- .../beta/service_binding_internal.go | 27 +++++++++---------- .../beta/tcp_route_internal.go | 27 +++++++++---------- .../beta/tls_route_internal.go | 27 +++++++++---------- .../osconfig/alpha/guest_policy_internal.go | 27 +++++++++---------- .../alpha/os_policy_assignment_internal.go | 27 +++++++++---------- .../osconfig/beta/guest_policy_internal.go | 27 +++++++++---------- .../beta/os_policy_assignment_internal.go | 27 +++++++++---------- .../osconfig/os_policy_assignment_internal.go | 27 +++++++++---------- .../privateca/alpha/ca_pool_internal.go | 27 +++++++++---------- .../alpha/certificate_template_internal.go | 27 +++++++++---------- .../google/privateca/beta/ca_pool_internal.go | 27 +++++++++---------- .../beta/certificate_template_internal.go | 27 +++++++++---------- services/google/privateca/ca_pool_internal.go | 27 +++++++++---------- .../certificate_template_internal.go | 27 +++++++++---------- .../google/pubsub/alpha/topic_internal.go | 26 +++++++++--------- services/google/pubsub/beta/topic_internal.go | 26 +++++++++--------- services/google/pubsub/topic_internal.go | 26 +++++++++--------- .../google/storage/alpha/bucket_internal.go | 27 +++++++++---------- .../google/storage/beta/bucket_internal.go | 27 +++++++++---------- services/google/storage/bucket_internal.go | 27 +++++++++---------- .../google/vmware/alpha/cluster_internal.go | 27 +++++++++---------- .../vpcaccess/alpha/connector_internal.go | 27 +++++++++---------- .../vpcaccess/beta/connector_internal.go | 27 +++++++++---------- .../google/vpcaccess/connector_internal.go | 27 +++++++++---------- 249 files changed, 3222 insertions(+), 3403 deletions(-) diff --git a/dcl/transport.go b/dcl/transport.go index b4fef669c..f54a1737c 100755 --- a/dcl/transport.go +++ b/dcl/transport.go @@ -92,6 +92,10 @@ func SendRequest(ctx context.Context, c *Config, verb, url string, body *bytes.B } } + if body == nil { + // A nil value indicates an empty request body. + body = &bytes.Buffer{} + } bodyBytes := body.Bytes() req, err := http.NewRequestWithContext(ctx, verb, u, bytes.NewReader(bodyBytes)) if err != nil { diff --git a/services/google/apigee/alpha/environment_group_attachment_internal.go b/services/google/apigee/alpha/environment_group_attachment_internal.go index 21f65c8a4..c79ad5323 100755 --- a/services/google/apigee/alpha/environment_group_attachment_internal.go +++ b/services/google/apigee/alpha/environment_group_attachment_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -191,20 +190,20 @@ func (op *deleteEnvironmentGroupAttachmentOperation) do(ctx context.Context, r * return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetEnvironmentGroupAttachment(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetEnvironmentGroupAttachment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/apigee/alpha/environment_group_internal.go b/services/google/apigee/alpha/environment_group_internal.go index e4ef459ba..f2b6319cb 100755 --- a/services/google/apigee/alpha/environment_group_internal.go +++ b/services/google/apigee/alpha/environment_group_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -271,20 +270,20 @@ func (op *deleteEnvironmentGroupOperation) do(ctx context.Context, r *Environmen return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetEnvironmentGroup(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetEnvironmentGroup(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/apigee/alpha/environment_internal.go b/services/google/apigee/alpha/environment_internal.go index 67f30070b..c09335416 100755 --- a/services/google/apigee/alpha/environment_internal.go +++ b/services/google/apigee/alpha/environment_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -231,20 +230,20 @@ func (op *deleteEnvironmentOperation) do(ctx context.Context, r *Environment, c return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetEnvironment(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetEnvironment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/apigee/alpha/instance_internal.go b/services/google/apigee/alpha/instance_internal.go index e44753d5b..7d36dda71 100755 --- a/services/google/apigee/alpha/instance_internal.go +++ b/services/google/apigee/alpha/instance_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -194,20 +193,20 @@ func (op *deleteInstanceOperation) do(ctx context.Context, r *Instance, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetInstance(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetInstance(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/apigee/alpha/organization_internal.go b/services/google/apigee/alpha/organization_internal.go index b8802dc63..8a9d85ac2 100755 --- a/services/google/apigee/alpha/organization_internal.go +++ b/services/google/apigee/alpha/organization_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -276,20 +275,20 @@ func (op *deleteOrganizationOperation) do(ctx context.Context, r *Organization, return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetOrganization(ctx, r) - if !dcl.IsNotFoundOrCode(err, 403) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetOrganization(ctx, r) + if dcl.IsNotFoundOrCode(err, 403) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/apigee/beta/environment_group_attachment_internal.go b/services/google/apigee/beta/environment_group_attachment_internal.go index 4be08677b..fd8707e7c 100755 --- a/services/google/apigee/beta/environment_group_attachment_internal.go +++ b/services/google/apigee/beta/environment_group_attachment_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -191,20 +190,20 @@ func (op *deleteEnvironmentGroupAttachmentOperation) do(ctx context.Context, r * return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetEnvironmentGroupAttachment(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetEnvironmentGroupAttachment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/apigee/beta/environment_group_internal.go b/services/google/apigee/beta/environment_group_internal.go index a6d1acf79..89583eb2f 100755 --- a/services/google/apigee/beta/environment_group_internal.go +++ b/services/google/apigee/beta/environment_group_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -271,20 +270,20 @@ func (op *deleteEnvironmentGroupOperation) do(ctx context.Context, r *Environmen return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetEnvironmentGroup(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetEnvironmentGroup(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/apigee/beta/environment_internal.go b/services/google/apigee/beta/environment_internal.go index eed20dbd5..0f9cc4b94 100755 --- a/services/google/apigee/beta/environment_internal.go +++ b/services/google/apigee/beta/environment_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -231,20 +230,20 @@ func (op *deleteEnvironmentOperation) do(ctx context.Context, r *Environment, c return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetEnvironment(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetEnvironment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/apigee/beta/instance_internal.go b/services/google/apigee/beta/instance_internal.go index 7a1b30375..6d6b36ae0 100755 --- a/services/google/apigee/beta/instance_internal.go +++ b/services/google/apigee/beta/instance_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -194,20 +193,20 @@ func (op *deleteInstanceOperation) do(ctx context.Context, r *Instance, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetInstance(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetInstance(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/apigee/beta/organization_internal.go b/services/google/apigee/beta/organization_internal.go index 1f7447564..503ca08c7 100755 --- a/services/google/apigee/beta/organization_internal.go +++ b/services/google/apigee/beta/organization_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -276,20 +275,20 @@ func (op *deleteOrganizationOperation) do(ctx context.Context, r *Organization, return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetOrganization(ctx, r) - if !dcl.IsNotFoundOrCode(err, 403) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetOrganization(ctx, r) + if dcl.IsNotFoundOrCode(err, 403) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/apigee/environment_group_attachment_internal.go b/services/google/apigee/environment_group_attachment_internal.go index 2870419b4..1c12ba91e 100755 --- a/services/google/apigee/environment_group_attachment_internal.go +++ b/services/google/apigee/environment_group_attachment_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -191,20 +190,20 @@ func (op *deleteEnvironmentGroupAttachmentOperation) do(ctx context.Context, r * return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetEnvironmentGroupAttachment(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetEnvironmentGroupAttachment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/apigee/environment_group_internal.go b/services/google/apigee/environment_group_internal.go index 62fa23e74..dc9360b7b 100755 --- a/services/google/apigee/environment_group_internal.go +++ b/services/google/apigee/environment_group_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -271,20 +270,20 @@ func (op *deleteEnvironmentGroupOperation) do(ctx context.Context, r *Environmen return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetEnvironmentGroup(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetEnvironmentGroup(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/apigee/environment_internal.go b/services/google/apigee/environment_internal.go index 3d07a9625..c5a435139 100755 --- a/services/google/apigee/environment_internal.go +++ b/services/google/apigee/environment_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -231,20 +230,20 @@ func (op *deleteEnvironmentOperation) do(ctx context.Context, r *Environment, c return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetEnvironment(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetEnvironment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/apigee/instance_internal.go b/services/google/apigee/instance_internal.go index ab2db01fa..8648630d5 100755 --- a/services/google/apigee/instance_internal.go +++ b/services/google/apigee/instance_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -194,20 +193,20 @@ func (op *deleteInstanceOperation) do(ctx context.Context, r *Instance, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetInstance(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetInstance(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/apigee/organization_internal.go b/services/google/apigee/organization_internal.go index 31e569b7e..bef23d6ed 100755 --- a/services/google/apigee/organization_internal.go +++ b/services/google/apigee/organization_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -276,20 +275,20 @@ func (op *deleteOrganizationOperation) do(ctx context.Context, r *Organization, return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetOrganization(ctx, r) - if !dcl.IsNotFoundOrCode(err, 403) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetOrganization(ctx, r) + if dcl.IsNotFoundOrCode(err, 403) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/assuredworkloads/alpha/workload_internal.go b/services/google/assuredworkloads/alpha/workload_internal.go index c2d4b61dc..abe658aba 100755 --- a/services/google/assuredworkloads/alpha/workload_internal.go +++ b/services/google/assuredworkloads/alpha/workload_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -309,20 +308,20 @@ func (op *deleteWorkloadOperation) do(ctx context.Context, r *Workload, c *Clien return fmt.Errorf("failed to delete Workload: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetWorkload(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetWorkload(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/assuredworkloads/beta/workload_internal.go b/services/google/assuredworkloads/beta/workload_internal.go index 7d26123a1..25a6f5cbb 100755 --- a/services/google/assuredworkloads/beta/workload_internal.go +++ b/services/google/assuredworkloads/beta/workload_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -309,20 +308,20 @@ func (op *deleteWorkloadOperation) do(ctx context.Context, r *Workload, c *Clien return fmt.Errorf("failed to delete Workload: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetWorkload(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetWorkload(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/assuredworkloads/workload_internal.go b/services/google/assuredworkloads/workload_internal.go index 8c8e310e4..2368da54f 100755 --- a/services/google/assuredworkloads/workload_internal.go +++ b/services/google/assuredworkloads/workload_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -309,20 +308,20 @@ func (op *deleteWorkloadOperation) do(ctx context.Context, r *Workload, c *Clien return fmt.Errorf("failed to delete Workload: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetWorkload(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetWorkload(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/bigquery/alpha/dataset_internal.go b/services/google/bigquery/alpha/dataset_internal.go index 127988c9c..5c808b4cf 100755 --- a/services/google/bigquery/alpha/dataset_internal.go +++ b/services/google/bigquery/alpha/dataset_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -338,20 +337,20 @@ func (op *deleteDatasetOperation) do(ctx context.Context, r *Dataset, c *Client) return fmt.Errorf("failed to delete Dataset: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetDataset(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetDataset(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/bigquery/alpha/routine_internal.go b/services/google/bigquery/alpha/routine_internal.go index 943f87f6f..7ab63572f 100755 --- a/services/google/bigquery/alpha/routine_internal.go +++ b/services/google/bigquery/alpha/routine_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -369,20 +368,20 @@ func (op *deleteRoutineOperation) do(ctx context.Context, r *Routine, c *Client) return fmt.Errorf("failed to delete Routine: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetRoutine(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetRoutine(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/bigquery/beta/dataset_internal.go b/services/google/bigquery/beta/dataset_internal.go index dd4d27b18..30b3bc21c 100755 --- a/services/google/bigquery/beta/dataset_internal.go +++ b/services/google/bigquery/beta/dataset_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -338,20 +337,20 @@ func (op *deleteDatasetOperation) do(ctx context.Context, r *Dataset, c *Client) return fmt.Errorf("failed to delete Dataset: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetDataset(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetDataset(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/bigquery/beta/routine_internal.go b/services/google/bigquery/beta/routine_internal.go index 8255e2e9b..df2245e73 100755 --- a/services/google/bigquery/beta/routine_internal.go +++ b/services/google/bigquery/beta/routine_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -369,20 +368,20 @@ func (op *deleteRoutineOperation) do(ctx context.Context, r *Routine, c *Client) return fmt.Errorf("failed to delete Routine: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetRoutine(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetRoutine(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/bigquery/dataset_internal.go b/services/google/bigquery/dataset_internal.go index 3f856813b..01c08a56d 100755 --- a/services/google/bigquery/dataset_internal.go +++ b/services/google/bigquery/dataset_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -338,20 +337,20 @@ func (op *deleteDatasetOperation) do(ctx context.Context, r *Dataset, c *Client) return fmt.Errorf("failed to delete Dataset: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetDataset(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetDataset(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/bigquery/routine_internal.go b/services/google/bigquery/routine_internal.go index 5b36694bc..6f0a24fe7 100755 --- a/services/google/bigquery/routine_internal.go +++ b/services/google/bigquery/routine_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -369,20 +368,20 @@ func (op *deleteRoutineOperation) do(ctx context.Context, r *Routine, c *Client) return fmt.Errorf("failed to delete Routine: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetRoutine(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetRoutine(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/bigqueryreservation/alpha/assignment_internal.go b/services/google/bigqueryreservation/alpha/assignment_internal.go index 5c59f4a0b..76c6e5fb6 100755 --- a/services/google/bigqueryreservation/alpha/assignment_internal.go +++ b/services/google/bigqueryreservation/alpha/assignment_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -193,20 +192,20 @@ func (op *deleteAssignmentOperation) do(ctx context.Context, r *Assignment, c *C return fmt.Errorf("failed to delete Assignment: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetAssignment(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetAssignment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/bigqueryreservation/alpha/capacity_commitment_internal.go b/services/google/bigqueryreservation/alpha/capacity_commitment_internal.go index 213cfae59..04738aa5d 100755 --- a/services/google/bigqueryreservation/alpha/capacity_commitment_internal.go +++ b/services/google/bigqueryreservation/alpha/capacity_commitment_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -283,20 +282,20 @@ func (op *deleteCapacityCommitmentOperation) do(ctx context.Context, r *Capacity return fmt.Errorf("failed to delete CapacityCommitment: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetCapacityCommitment(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetCapacityCommitment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/bigqueryreservation/alpha/reservation_internal.go b/services/google/bigqueryreservation/alpha/reservation_internal.go index ea6f0fdc7..a04d4c44a 100755 --- a/services/google/bigqueryreservation/alpha/reservation_internal.go +++ b/services/google/bigqueryreservation/alpha/reservation_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -263,20 +262,20 @@ func (op *deleteReservationOperation) do(ctx context.Context, r *Reservation, c return fmt.Errorf("failed to delete Reservation: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetReservation(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetReservation(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/bigqueryreservation/assignment_internal.go b/services/google/bigqueryreservation/assignment_internal.go index bcfd91367..eab11429f 100755 --- a/services/google/bigqueryreservation/assignment_internal.go +++ b/services/google/bigqueryreservation/assignment_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -193,20 +192,20 @@ func (op *deleteAssignmentOperation) do(ctx context.Context, r *Assignment, c *C return fmt.Errorf("failed to delete Assignment: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetAssignment(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetAssignment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/bigqueryreservation/beta/assignment_internal.go b/services/google/bigqueryreservation/beta/assignment_internal.go index 317c591ba..a15c97228 100755 --- a/services/google/bigqueryreservation/beta/assignment_internal.go +++ b/services/google/bigqueryreservation/beta/assignment_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -193,20 +192,20 @@ func (op *deleteAssignmentOperation) do(ctx context.Context, r *Assignment, c *C return fmt.Errorf("failed to delete Assignment: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetAssignment(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetAssignment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/bigqueryreservation/beta/capacity_commitment_internal.go b/services/google/bigqueryreservation/beta/capacity_commitment_internal.go index 6c5b5084f..1e4336784 100755 --- a/services/google/bigqueryreservation/beta/capacity_commitment_internal.go +++ b/services/google/bigqueryreservation/beta/capacity_commitment_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -283,20 +282,20 @@ func (op *deleteCapacityCommitmentOperation) do(ctx context.Context, r *Capacity return fmt.Errorf("failed to delete CapacityCommitment: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetCapacityCommitment(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetCapacityCommitment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/bigqueryreservation/beta/reservation_internal.go b/services/google/bigqueryreservation/beta/reservation_internal.go index 7addeb009..8903ce87d 100755 --- a/services/google/bigqueryreservation/beta/reservation_internal.go +++ b/services/google/bigqueryreservation/beta/reservation_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -263,20 +262,20 @@ func (op *deleteReservationOperation) do(ctx context.Context, r *Reservation, c return fmt.Errorf("failed to delete Reservation: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetReservation(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetReservation(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/bigqueryreservation/capacity_commitment_internal.go b/services/google/bigqueryreservation/capacity_commitment_internal.go index aa4c3aba5..007b41ede 100755 --- a/services/google/bigqueryreservation/capacity_commitment_internal.go +++ b/services/google/bigqueryreservation/capacity_commitment_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -283,20 +282,20 @@ func (op *deleteCapacityCommitmentOperation) do(ctx context.Context, r *Capacity return fmt.Errorf("failed to delete CapacityCommitment: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetCapacityCommitment(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetCapacityCommitment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/bigqueryreservation/reservation_internal.go b/services/google/bigqueryreservation/reservation_internal.go index 2c7ca8ab8..266e26196 100755 --- a/services/google/bigqueryreservation/reservation_internal.go +++ b/services/google/bigqueryreservation/reservation_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -260,20 +259,20 @@ func (op *deleteReservationOperation) do(ctx context.Context, r *Reservation, c return fmt.Errorf("failed to delete Reservation: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetReservation(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetReservation(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/billingbudgets/alpha/budget_internal.go b/services/google/billingbudgets/alpha/budget_internal.go index 1c869f124..7eb93351c 100755 --- a/services/google/billingbudgets/alpha/budget_internal.go +++ b/services/google/billingbudgets/alpha/budget_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -333,20 +332,20 @@ func (op *deleteBudgetOperation) do(ctx context.Context, r *Budget, c *Client) e return fmt.Errorf("failed to delete Budget: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetBudget(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetBudget(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/billingbudgets/beta/budget_internal.go b/services/google/billingbudgets/beta/budget_internal.go index efe0448fc..fea077be9 100755 --- a/services/google/billingbudgets/beta/budget_internal.go +++ b/services/google/billingbudgets/beta/budget_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -333,20 +332,20 @@ func (op *deleteBudgetOperation) do(ctx context.Context, r *Budget, c *Client) e return fmt.Errorf("failed to delete Budget: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetBudget(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetBudget(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/billingbudgets/budget_internal.go b/services/google/billingbudgets/budget_internal.go index fc3e2f2ca..af39bfea8 100755 --- a/services/google/billingbudgets/budget_internal.go +++ b/services/google/billingbudgets/budget_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -333,20 +332,20 @@ func (op *deleteBudgetOperation) do(ctx context.Context, r *Budget, c *Client) e return fmt.Errorf("failed to delete Budget: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetBudget(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetBudget(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/binaryauthorization/alpha/attestor_internal.go b/services/google/binaryauthorization/alpha/attestor_internal.go index 72e311b0c..40e4b9f16 100755 --- a/services/google/binaryauthorization/alpha/attestor_internal.go +++ b/services/google/binaryauthorization/alpha/attestor_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -271,20 +270,20 @@ func (op *deleteAttestorOperation) do(ctx context.Context, r *Attestor, c *Clien return fmt.Errorf("failed to delete Attestor: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetAttestor(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetAttestor(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/binaryauthorization/attestor_internal.go b/services/google/binaryauthorization/attestor_internal.go index 9d3b84935..ef3f55d84 100755 --- a/services/google/binaryauthorization/attestor_internal.go +++ b/services/google/binaryauthorization/attestor_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -271,20 +270,20 @@ func (op *deleteAttestorOperation) do(ctx context.Context, r *Attestor, c *Clien return fmt.Errorf("failed to delete Attestor: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetAttestor(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetAttestor(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/binaryauthorization/beta/attestor_internal.go b/services/google/binaryauthorization/beta/attestor_internal.go index c97c34efe..613652424 100755 --- a/services/google/binaryauthorization/beta/attestor_internal.go +++ b/services/google/binaryauthorization/beta/attestor_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -271,20 +270,20 @@ func (op *deleteAttestorOperation) do(ctx context.Context, r *Attestor, c *Clien return fmt.Errorf("failed to delete Attestor: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetAttestor(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetAttestor(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/cloudbuild/alpha/worker_pool_internal.go b/services/google/cloudbuild/alpha/worker_pool_internal.go index ba144a381..ad0747880 100755 --- a/services/google/cloudbuild/alpha/worker_pool_internal.go +++ b/services/google/cloudbuild/alpha/worker_pool_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -356,20 +355,20 @@ func (op *deleteWorkerPoolOperation) do(ctx context.Context, r *WorkerPool, c *C return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetWorkerPool(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetWorkerPool(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/cloudbuild/beta/worker_pool_internal.go b/services/google/cloudbuild/beta/worker_pool_internal.go index 66c1c6ed1..bca566ddd 100755 --- a/services/google/cloudbuild/beta/worker_pool_internal.go +++ b/services/google/cloudbuild/beta/worker_pool_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -356,20 +355,20 @@ func (op *deleteWorkerPoolOperation) do(ctx context.Context, r *WorkerPool, c *C return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetWorkerPool(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetWorkerPool(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/cloudbuild/worker_pool_internal.go b/services/google/cloudbuild/worker_pool_internal.go index 346b24cca..9122735de 100755 --- a/services/google/cloudbuild/worker_pool_internal.go +++ b/services/google/cloudbuild/worker_pool_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -356,20 +355,20 @@ func (op *deleteWorkerPoolOperation) do(ctx context.Context, r *WorkerPool, c *C return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetWorkerPool(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetWorkerPool(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/clouddeploy/alpha/delivery_pipeline_internal.go b/services/google/clouddeploy/alpha/delivery_pipeline_internal.go index 2683bbd49..f9b2eb1e1 100755 --- a/services/google/clouddeploy/alpha/delivery_pipeline_internal.go +++ b/services/google/clouddeploy/alpha/delivery_pipeline_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -372,20 +371,20 @@ func (op *deleteDeliveryPipelineOperation) do(ctx context.Context, r *DeliveryPi return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetDeliveryPipeline(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetDeliveryPipeline(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/clouddeploy/alpha/target_internal.go b/services/google/clouddeploy/alpha/target_internal.go index f1d4c6a08..61797e3e1 100755 --- a/services/google/clouddeploy/alpha/target_internal.go +++ b/services/google/clouddeploy/alpha/target_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -368,20 +367,20 @@ func (op *deleteTargetOperation) do(ctx context.Context, r *Target, c *Client) e return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTarget(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTarget(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/clouddeploy/beta/delivery_pipeline_internal.go b/services/google/clouddeploy/beta/delivery_pipeline_internal.go index a3ca4dcab..f5ccbbf01 100755 --- a/services/google/clouddeploy/beta/delivery_pipeline_internal.go +++ b/services/google/clouddeploy/beta/delivery_pipeline_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -372,20 +371,20 @@ func (op *deleteDeliveryPipelineOperation) do(ctx context.Context, r *DeliveryPi return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetDeliveryPipeline(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetDeliveryPipeline(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/clouddeploy/beta/target_internal.go b/services/google/clouddeploy/beta/target_internal.go index 3bb3b9e62..59c44c5d0 100755 --- a/services/google/clouddeploy/beta/target_internal.go +++ b/services/google/clouddeploy/beta/target_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -368,20 +367,20 @@ func (op *deleteTargetOperation) do(ctx context.Context, r *Target, c *Client) e return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTarget(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTarget(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/clouddeploy/delivery_pipeline_internal.go b/services/google/clouddeploy/delivery_pipeline_internal.go index ef2ade93d..db270f1a6 100755 --- a/services/google/clouddeploy/delivery_pipeline_internal.go +++ b/services/google/clouddeploy/delivery_pipeline_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -372,20 +371,20 @@ func (op *deleteDeliveryPipelineOperation) do(ctx context.Context, r *DeliveryPi return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetDeliveryPipeline(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetDeliveryPipeline(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/clouddeploy/target_internal.go b/services/google/clouddeploy/target_internal.go index 335207eb4..1ebc13b5b 100755 --- a/services/google/clouddeploy/target_internal.go +++ b/services/google/clouddeploy/target_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -368,20 +367,20 @@ func (op *deleteTargetOperation) do(ctx context.Context, r *Target, c *Client) e return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTarget(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTarget(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/cloudfunctions/alpha/function_internal.go b/services/google/cloudfunctions/alpha/function_internal.go index 5ca760578..4b1398148 100755 --- a/services/google/cloudfunctions/alpha/function_internal.go +++ b/services/google/cloudfunctions/alpha/function_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -373,20 +372,20 @@ func (op *deleteFunctionOperation) do(ctx context.Context, r *Function, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetFunction(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetFunction(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/cloudfunctions/beta/function_internal.go b/services/google/cloudfunctions/beta/function_internal.go index a99fa8017..1f83d68ba 100755 --- a/services/google/cloudfunctions/beta/function_internal.go +++ b/services/google/cloudfunctions/beta/function_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -373,20 +372,20 @@ func (op *deleteFunctionOperation) do(ctx context.Context, r *Function, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetFunction(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetFunction(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/cloudfunctions/function_internal.go b/services/google/cloudfunctions/function_internal.go index 01caaa6e4..429e06323 100755 --- a/services/google/cloudfunctions/function_internal.go +++ b/services/google/cloudfunctions/function_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -373,20 +372,20 @@ func (op *deleteFunctionOperation) do(ctx context.Context, r *Function, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetFunction(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetFunction(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/cloudidentity/alpha/group_internal.go b/services/google/cloudidentity/alpha/group_internal.go index 9e16ee924..277cfc6d2 100755 --- a/services/google/cloudidentity/alpha/group_internal.go +++ b/services/google/cloudidentity/alpha/group_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -329,20 +328,20 @@ func (op *deleteGroupOperation) do(ctx context.Context, r *Group, c *Client) err return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetGroup(ctx, r) - if !dcl.IsNotFoundOrCode(err, 403) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetGroup(ctx, r) + if dcl.IsNotFoundOrCode(err, 403) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/cloudidentity/alpha/membership_internal.go b/services/google/cloudidentity/alpha/membership_internal.go index ab5754630..75d5c619e 100755 --- a/services/google/cloudidentity/alpha/membership_internal.go +++ b/services/google/cloudidentity/alpha/membership_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -291,20 +290,20 @@ func (op *deleteMembershipOperation) do(ctx context.Context, r *Membership, c *C return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetMembership(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetMembership(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/cloudidentity/beta/group_internal.go b/services/google/cloudidentity/beta/group_internal.go index 789a3c902..7078ec381 100755 --- a/services/google/cloudidentity/beta/group_internal.go +++ b/services/google/cloudidentity/beta/group_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -329,20 +328,20 @@ func (op *deleteGroupOperation) do(ctx context.Context, r *Group, c *Client) err return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetGroup(ctx, r) - if !dcl.IsNotFoundOrCode(err, 403) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetGroup(ctx, r) + if dcl.IsNotFoundOrCode(err, 403) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/cloudidentity/beta/membership_internal.go b/services/google/cloudidentity/beta/membership_internal.go index bd6306aec..8226fa233 100755 --- a/services/google/cloudidentity/beta/membership_internal.go +++ b/services/google/cloudidentity/beta/membership_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -291,20 +290,20 @@ func (op *deleteMembershipOperation) do(ctx context.Context, r *Membership, c *C return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetMembership(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetMembership(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/cloudidentity/group_internal.go b/services/google/cloudidentity/group_internal.go index e977d3ebc..162760b03 100755 --- a/services/google/cloudidentity/group_internal.go +++ b/services/google/cloudidentity/group_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -335,20 +334,20 @@ func (op *deleteGroupOperation) do(ctx context.Context, r *Group, c *Client) err return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetGroup(ctx, r) - if !dcl.IsNotFoundOrCode(err, 403) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetGroup(ctx, r) + if dcl.IsNotFoundOrCode(err, 403) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/cloudidentity/membership_internal.go b/services/google/cloudidentity/membership_internal.go index 18d15bfd2..ef8351f03 100755 --- a/services/google/cloudidentity/membership_internal.go +++ b/services/google/cloudidentity/membership_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -295,20 +294,20 @@ func (op *deleteMembershipOperation) do(ctx context.Context, r *Membership, c *C return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetMembership(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetMembership(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/cloudresourcemanager/alpha/tag_key_internal.go b/services/google/cloudresourcemanager/alpha/tag_key_internal.go index 15e007ef1..6a5419bdb 100755 --- a/services/google/cloudresourcemanager/alpha/tag_key_internal.go +++ b/services/google/cloudresourcemanager/alpha/tag_key_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -217,20 +216,20 @@ func (op *deleteTagKeyOperation) do(ctx context.Context, r *TagKey, c *Client) e return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTagKey(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTagKey(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/cloudresourcemanager/beta/tag_key_internal.go b/services/google/cloudresourcemanager/beta/tag_key_internal.go index 49e096d02..670fba364 100755 --- a/services/google/cloudresourcemanager/beta/tag_key_internal.go +++ b/services/google/cloudresourcemanager/beta/tag_key_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -217,20 +216,20 @@ func (op *deleteTagKeyOperation) do(ctx context.Context, r *TagKey, c *Client) e return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTagKey(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTagKey(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/cloudresourcemanager/tag_key_internal.go b/services/google/cloudresourcemanager/tag_key_internal.go index 2593dec9c..7ecb70d90 100755 --- a/services/google/cloudresourcemanager/tag_key_internal.go +++ b/services/google/cloudresourcemanager/tag_key_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -217,20 +216,20 @@ func (op *deleteTagKeyOperation) do(ctx context.Context, r *TagKey, c *Client) e return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTagKey(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTagKey(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/cloudscheduler/alpha/job_internal.go b/services/google/cloudscheduler/alpha/job_internal.go index 761013c7b..a0d7d23ab 100755 --- a/services/google/cloudscheduler/alpha/job_internal.go +++ b/services/google/cloudscheduler/alpha/job_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -358,20 +357,20 @@ func (op *deleteJobOperation) do(ctx context.Context, r *Job, c *Client) error { return fmt.Errorf("failed to delete Job: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetJob(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetJob(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/cloudscheduler/beta/job_internal.go b/services/google/cloudscheduler/beta/job_internal.go index 731e500b1..b49e47fd9 100755 --- a/services/google/cloudscheduler/beta/job_internal.go +++ b/services/google/cloudscheduler/beta/job_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -358,20 +357,20 @@ func (op *deleteJobOperation) do(ctx context.Context, r *Job, c *Client) error { return fmt.Errorf("failed to delete Job: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetJob(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetJob(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/cloudscheduler/job_internal.go b/services/google/cloudscheduler/job_internal.go index 4d2307f14..b1beb9ded 100755 --- a/services/google/cloudscheduler/job_internal.go +++ b/services/google/cloudscheduler/job_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -358,20 +357,20 @@ func (op *deleteJobOperation) do(ctx context.Context, r *Job, c *Client) error { return fmt.Errorf("failed to delete Job: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetJob(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetJob(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/alpha/forwarding_rule_internal.go b/services/google/compute/alpha/forwarding_rule_internal.go index 69347fdce..da83e4c55 100755 --- a/services/google/compute/alpha/forwarding_rule_internal.go +++ b/services/google/compute/alpha/forwarding_rule_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -468,20 +467,20 @@ func (op *deleteForwardingRuleOperation) do(ctx context.Context, r *ForwardingRu return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetForwardingRule(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetForwardingRule(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/alpha/instance_group_manager_internal.go b/services/google/compute/alpha/instance_group_manager_internal.go index 5f1ce0c82..5cb0b1392 100755 --- a/services/google/compute/alpha/instance_group_manager_internal.go +++ b/services/google/compute/alpha/instance_group_manager_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -619,20 +618,20 @@ func (op *deleteInstanceGroupManagerOperation) do(ctx context.Context, r *Instan return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetInstanceGroupManager(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetInstanceGroupManager(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/alpha/instance_internal.go b/services/google/compute/alpha/instance_internal.go index 8bdcc535e..bc2860406 100755 --- a/services/google/compute/alpha/instance_internal.go +++ b/services/google/compute/alpha/instance_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -1036,20 +1035,20 @@ func (op *deleteInstanceOperation) do(ctx context.Context, r *Instance, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetInstance(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetInstance(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/alpha/interconnect_attachment_internal.go b/services/google/compute/alpha/interconnect_attachment_internal.go index b82bd0460..5492a2071 100755 --- a/services/google/compute/alpha/interconnect_attachment_internal.go +++ b/services/google/compute/alpha/interconnect_attachment_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -323,20 +322,20 @@ func (op *deleteInterconnectAttachmentOperation) do(ctx context.Context, r *Inte return fmt.Errorf("failed to delete InterconnectAttachment: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetInterconnectAttachment(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetInterconnectAttachment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/alpha/network_internal.go b/services/google/compute/alpha/network_internal.go index 6f9f1be73..756179e0b 100755 --- a/services/google/compute/alpha/network_internal.go +++ b/services/google/compute/alpha/network_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -237,20 +236,20 @@ func (op *deleteNetworkOperation) do(ctx context.Context, r *Network, c *Client) return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetNetwork(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetNetwork(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/alpha/packet_mirroring_internal.go b/services/google/compute/alpha/packet_mirroring_internal.go index 637c56334..e41f7627f 100755 --- a/services/google/compute/alpha/packet_mirroring_internal.go +++ b/services/google/compute/alpha/packet_mirroring_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -345,20 +344,20 @@ func (op *deletePacketMirroringOperation) do(ctx context.Context, r *PacketMirro return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetPacketMirroring(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetPacketMirroring(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/alpha/route_internal.go b/services/google/compute/alpha/route_internal.go index 8e17d0679..834d9131d 100755 --- a/services/google/compute/alpha/route_internal.go +++ b/services/google/compute/alpha/route_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -203,20 +202,20 @@ func (op *deleteRouteOperation) do(ctx context.Context, r *Route, c *Client) err return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetRoute(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetRoute(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/alpha/service_attachment_internal.go b/services/google/compute/alpha/service_attachment_internal.go index 698132822..c328c0123 100755 --- a/services/google/compute/alpha/service_attachment_internal.go +++ b/services/google/compute/alpha/service_attachment_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -332,20 +331,20 @@ func (op *deleteServiceAttachmentOperation) do(ctx context.Context, r *ServiceAt return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetServiceAttachment(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetServiceAttachment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/alpha/subnetwork_internal.go b/services/google/compute/alpha/subnetwork_internal.go index 33e489e59..f9627814d 100755 --- a/services/google/compute/alpha/subnetwork_internal.go +++ b/services/google/compute/alpha/subnetwork_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -426,20 +425,20 @@ func (op *deleteSubnetworkOperation) do(ctx context.Context, r *Subnetwork, c *C return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetSubnetwork(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetSubnetwork(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/alpha/vpn_tunnel_internal.go b/services/google/compute/alpha/vpn_tunnel_internal.go index 2c23caacb..fe0a7623b 100755 --- a/services/google/compute/alpha/vpn_tunnel_internal.go +++ b/services/google/compute/alpha/vpn_tunnel_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -268,20 +267,20 @@ func (op *deleteVpnTunnelOperation) do(ctx context.Context, r *VpnTunnel, c *Cli return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetVpnTunnel(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetVpnTunnel(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/beta/forwarding_rule_internal.go b/services/google/compute/beta/forwarding_rule_internal.go index 93c2e220a..7d105081a 100755 --- a/services/google/compute/beta/forwarding_rule_internal.go +++ b/services/google/compute/beta/forwarding_rule_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -468,20 +467,20 @@ func (op *deleteForwardingRuleOperation) do(ctx context.Context, r *ForwardingRu return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetForwardingRule(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetForwardingRule(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/beta/instance_group_manager_internal.go b/services/google/compute/beta/instance_group_manager_internal.go index 87dbb3d90..1cc3e8efa 100755 --- a/services/google/compute/beta/instance_group_manager_internal.go +++ b/services/google/compute/beta/instance_group_manager_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -619,20 +618,20 @@ func (op *deleteInstanceGroupManagerOperation) do(ctx context.Context, r *Instan return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetInstanceGroupManager(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetInstanceGroupManager(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/beta/instance_internal.go b/services/google/compute/beta/instance_internal.go index 62f6d6d67..0634d8102 100755 --- a/services/google/compute/beta/instance_internal.go +++ b/services/google/compute/beta/instance_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -1036,20 +1035,20 @@ func (op *deleteInstanceOperation) do(ctx context.Context, r *Instance, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetInstance(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetInstance(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/beta/interconnect_attachment_internal.go b/services/google/compute/beta/interconnect_attachment_internal.go index c339f07d6..d73a252b4 100755 --- a/services/google/compute/beta/interconnect_attachment_internal.go +++ b/services/google/compute/beta/interconnect_attachment_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -323,20 +322,20 @@ func (op *deleteInterconnectAttachmentOperation) do(ctx context.Context, r *Inte return fmt.Errorf("failed to delete InterconnectAttachment: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetInterconnectAttachment(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetInterconnectAttachment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/beta/network_internal.go b/services/google/compute/beta/network_internal.go index 76cabf2e7..62d430aab 100755 --- a/services/google/compute/beta/network_internal.go +++ b/services/google/compute/beta/network_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -237,20 +236,20 @@ func (op *deleteNetworkOperation) do(ctx context.Context, r *Network, c *Client) return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetNetwork(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetNetwork(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/beta/packet_mirroring_internal.go b/services/google/compute/beta/packet_mirroring_internal.go index e09fd8c6c..10cddf147 100755 --- a/services/google/compute/beta/packet_mirroring_internal.go +++ b/services/google/compute/beta/packet_mirroring_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -345,20 +344,20 @@ func (op *deletePacketMirroringOperation) do(ctx context.Context, r *PacketMirro return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetPacketMirroring(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetPacketMirroring(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/beta/route_internal.go b/services/google/compute/beta/route_internal.go index 13bad9f9d..f1d558007 100755 --- a/services/google/compute/beta/route_internal.go +++ b/services/google/compute/beta/route_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -203,20 +202,20 @@ func (op *deleteRouteOperation) do(ctx context.Context, r *Route, c *Client) err return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetRoute(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetRoute(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/beta/service_attachment_internal.go b/services/google/compute/beta/service_attachment_internal.go index e89d305b4..12fbca323 100755 --- a/services/google/compute/beta/service_attachment_internal.go +++ b/services/google/compute/beta/service_attachment_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -332,20 +331,20 @@ func (op *deleteServiceAttachmentOperation) do(ctx context.Context, r *ServiceAt return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetServiceAttachment(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetServiceAttachment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/beta/subnetwork_internal.go b/services/google/compute/beta/subnetwork_internal.go index 485e8ac6a..9f17bfd2c 100755 --- a/services/google/compute/beta/subnetwork_internal.go +++ b/services/google/compute/beta/subnetwork_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -426,20 +425,20 @@ func (op *deleteSubnetworkOperation) do(ctx context.Context, r *Subnetwork, c *C return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetSubnetwork(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetSubnetwork(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/beta/vpn_tunnel_internal.go b/services/google/compute/beta/vpn_tunnel_internal.go index 7d75bf31d..1f2bba6b0 100755 --- a/services/google/compute/beta/vpn_tunnel_internal.go +++ b/services/google/compute/beta/vpn_tunnel_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -268,20 +267,20 @@ func (op *deleteVpnTunnelOperation) do(ctx context.Context, r *VpnTunnel, c *Cli return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetVpnTunnel(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetVpnTunnel(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/forwarding_rule_internal.go b/services/google/compute/forwarding_rule_internal.go index 431fee616..f9b69bf1d 100755 --- a/services/google/compute/forwarding_rule_internal.go +++ b/services/google/compute/forwarding_rule_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -468,20 +467,20 @@ func (op *deleteForwardingRuleOperation) do(ctx context.Context, r *ForwardingRu return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetForwardingRule(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetForwardingRule(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/instance_group_manager_internal.go b/services/google/compute/instance_group_manager_internal.go index 92cabd8ef..7d27625b6 100755 --- a/services/google/compute/instance_group_manager_internal.go +++ b/services/google/compute/instance_group_manager_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -613,20 +612,20 @@ func (op *deleteInstanceGroupManagerOperation) do(ctx context.Context, r *Instan return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetInstanceGroupManager(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetInstanceGroupManager(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/instance_internal.go b/services/google/compute/instance_internal.go index 156f91692..078e21ce0 100755 --- a/services/google/compute/instance_internal.go +++ b/services/google/compute/instance_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -1036,20 +1035,20 @@ func (op *deleteInstanceOperation) do(ctx context.Context, r *Instance, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetInstance(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetInstance(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/interconnect_attachment_internal.go b/services/google/compute/interconnect_attachment_internal.go index 955b9b106..f16dfc310 100755 --- a/services/google/compute/interconnect_attachment_internal.go +++ b/services/google/compute/interconnect_attachment_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -317,20 +316,20 @@ func (op *deleteInterconnectAttachmentOperation) do(ctx context.Context, r *Inte return fmt.Errorf("failed to delete InterconnectAttachment: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetInterconnectAttachment(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetInterconnectAttachment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/network_internal.go b/services/google/compute/network_internal.go index 7464e7908..ccaabc5d0 100755 --- a/services/google/compute/network_internal.go +++ b/services/google/compute/network_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -237,20 +236,20 @@ func (op *deleteNetworkOperation) do(ctx context.Context, r *Network, c *Client) return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetNetwork(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetNetwork(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/packet_mirroring_internal.go b/services/google/compute/packet_mirroring_internal.go index f5ec7acf6..2287cc562 100755 --- a/services/google/compute/packet_mirroring_internal.go +++ b/services/google/compute/packet_mirroring_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -345,20 +344,20 @@ func (op *deletePacketMirroringOperation) do(ctx context.Context, r *PacketMirro return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetPacketMirroring(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetPacketMirroring(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/route_internal.go b/services/google/compute/route_internal.go index 92f6765ce..3623060c6 100755 --- a/services/google/compute/route_internal.go +++ b/services/google/compute/route_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -203,20 +202,20 @@ func (op *deleteRouteOperation) do(ctx context.Context, r *Route, c *Client) err return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetRoute(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetRoute(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/service_attachment_internal.go b/services/google/compute/service_attachment_internal.go index 1397eccc2..046ed0475 100755 --- a/services/google/compute/service_attachment_internal.go +++ b/services/google/compute/service_attachment_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -332,20 +331,20 @@ func (op *deleteServiceAttachmentOperation) do(ctx context.Context, r *ServiceAt return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetServiceAttachment(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetServiceAttachment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/subnetwork_internal.go b/services/google/compute/subnetwork_internal.go index e8746f9c7..fd5ab6703 100755 --- a/services/google/compute/subnetwork_internal.go +++ b/services/google/compute/subnetwork_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -426,20 +425,20 @@ func (op *deleteSubnetworkOperation) do(ctx context.Context, r *Subnetwork, c *C return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetSubnetwork(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetSubnetwork(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/compute/vpn_tunnel_internal.go b/services/google/compute/vpn_tunnel_internal.go index 24eacaf2a..7fadbee83 100755 --- a/services/google/compute/vpn_tunnel_internal.go +++ b/services/google/compute/vpn_tunnel_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -196,20 +195,20 @@ func (op *deleteVpnTunnelOperation) do(ctx context.Context, r *VpnTunnel, c *Cli return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetVpnTunnel(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetVpnTunnel(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/configcontroller/alpha/instance_internal.go b/services/google/configcontroller/alpha/instance_internal.go index b24f55dbc..15f0a177b 100755 --- a/services/google/configcontroller/alpha/instance_internal.go +++ b/services/google/configcontroller/alpha/instance_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -258,20 +257,20 @@ func (op *deleteInstanceOperation) do(ctx context.Context, r *Instance, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetInstance(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetInstance(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/containeranalysis/alpha/note_internal.go b/services/google/containeranalysis/alpha/note_internal.go index bd4ed9c4f..971c5e5c0 100755 --- a/services/google/containeranalysis/alpha/note_internal.go +++ b/services/google/containeranalysis/alpha/note_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -383,20 +382,20 @@ func (op *deleteNoteOperation) do(ctx context.Context, r *Note, c *Client) error return fmt.Errorf("failed to delete Note: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetNote(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetNote(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/containeranalysis/beta/note_internal.go b/services/google/containeranalysis/beta/note_internal.go index 3316b07aa..8bc4c5a6c 100755 --- a/services/google/containeranalysis/beta/note_internal.go +++ b/services/google/containeranalysis/beta/note_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -491,20 +490,20 @@ func (op *deleteNoteOperation) do(ctx context.Context, r *Note, c *Client) error return fmt.Errorf("failed to delete Note: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetNote(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetNote(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/containeranalysis/note_internal.go b/services/google/containeranalysis/note_internal.go index 2f2130464..935814e9a 100755 --- a/services/google/containeranalysis/note_internal.go +++ b/services/google/containeranalysis/note_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -480,20 +479,20 @@ func (op *deleteNoteOperation) do(ctx context.Context, r *Note, c *Client) error return fmt.Errorf("failed to delete Note: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetNote(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetNote(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/containeraws/alpha/cluster_internal.go b/services/google/containeraws/alpha/cluster_internal.go index 3d8d0a195..5e004fb19 100755 --- a/services/google/containeraws/alpha/cluster_internal.go +++ b/services/google/containeraws/alpha/cluster_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -501,20 +500,20 @@ func (op *deleteClusterOperation) do(ctx context.Context, r *Cluster, c *Client) return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetCluster(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetCluster(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/containeraws/alpha/node_pool_internal.go b/services/google/containeraws/alpha/node_pool_internal.go index 769906d02..f6a964164 100755 --- a/services/google/containeraws/alpha/node_pool_internal.go +++ b/services/google/containeraws/alpha/node_pool_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -435,20 +434,20 @@ func (op *deleteNodePoolOperation) do(ctx context.Context, r *NodePool, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetNodePool(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetNodePool(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/containeraws/beta/cluster_internal.go b/services/google/containeraws/beta/cluster_internal.go index 0cde225aa..50d4cbfbc 100755 --- a/services/google/containeraws/beta/cluster_internal.go +++ b/services/google/containeraws/beta/cluster_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -501,20 +500,20 @@ func (op *deleteClusterOperation) do(ctx context.Context, r *Cluster, c *Client) return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetCluster(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetCluster(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/containeraws/beta/node_pool_internal.go b/services/google/containeraws/beta/node_pool_internal.go index 15c6a240e..7f5a25ca0 100755 --- a/services/google/containeraws/beta/node_pool_internal.go +++ b/services/google/containeraws/beta/node_pool_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -435,20 +434,20 @@ func (op *deleteNodePoolOperation) do(ctx context.Context, r *NodePool, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetNodePool(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetNodePool(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/containeraws/cluster_internal.go b/services/google/containeraws/cluster_internal.go index feb26ec88..b4ec84fbc 100755 --- a/services/google/containeraws/cluster_internal.go +++ b/services/google/containeraws/cluster_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -477,20 +476,20 @@ func (op *deleteClusterOperation) do(ctx context.Context, r *Cluster, c *Client) return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetCluster(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetCluster(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/containeraws/node_pool_internal.go b/services/google/containeraws/node_pool_internal.go index d1f0e1122..767485346 100755 --- a/services/google/containeraws/node_pool_internal.go +++ b/services/google/containeraws/node_pool_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -427,20 +426,20 @@ func (op *deleteNodePoolOperation) do(ctx context.Context, r *NodePool, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetNodePool(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetNodePool(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/containerazure/alpha/azure_client_internal.go b/services/google/containerazure/alpha/azure_client_internal.go index 9ddf4a5cc..0fd1bee7a 100755 --- a/services/google/containerazure/alpha/azure_client_internal.go +++ b/services/google/containerazure/alpha/azure_client_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -208,20 +207,20 @@ func (op *deleteClientOperation) do(ctx context.Context, r *AzureClient, c *Clie return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetClient(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetClient(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/containerazure/alpha/cluster_internal.go b/services/google/containerazure/alpha/cluster_internal.go index 398f7c274..ddf5de3d3 100755 --- a/services/google/containerazure/alpha/cluster_internal.go +++ b/services/google/containerazure/alpha/cluster_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -477,20 +476,20 @@ func (op *deleteClusterOperation) do(ctx context.Context, r *Cluster, c *Client) return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetCluster(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetCluster(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/containerazure/alpha/node_pool_internal.go b/services/google/containerazure/alpha/node_pool_internal.go index 819e1b105..525a46785 100755 --- a/services/google/containerazure/alpha/node_pool_internal.go +++ b/services/google/containerazure/alpha/node_pool_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -391,20 +390,20 @@ func (op *deleteNodePoolOperation) do(ctx context.Context, r *NodePool, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetNodePool(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetNodePool(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/containerazure/azure_client_internal.go b/services/google/containerazure/azure_client_internal.go index ed4e49f40..e3486224c 100755 --- a/services/google/containerazure/azure_client_internal.go +++ b/services/google/containerazure/azure_client_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -208,20 +207,20 @@ func (op *deleteClientOperation) do(ctx context.Context, r *AzureClient, c *Clie return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetClient(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetClient(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/containerazure/beta/azure_client_internal.go b/services/google/containerazure/beta/azure_client_internal.go index c957265c1..8035c85a6 100755 --- a/services/google/containerazure/beta/azure_client_internal.go +++ b/services/google/containerazure/beta/azure_client_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -208,20 +207,20 @@ func (op *deleteClientOperation) do(ctx context.Context, r *AzureClient, c *Clie return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetClient(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetClient(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/containerazure/beta/cluster_internal.go b/services/google/containerazure/beta/cluster_internal.go index 5356745bb..bef511a89 100755 --- a/services/google/containerazure/beta/cluster_internal.go +++ b/services/google/containerazure/beta/cluster_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -477,20 +476,20 @@ func (op *deleteClusterOperation) do(ctx context.Context, r *Cluster, c *Client) return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetCluster(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetCluster(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/containerazure/beta/node_pool_internal.go b/services/google/containerazure/beta/node_pool_internal.go index b4dbc6b28..42e284493 100755 --- a/services/google/containerazure/beta/node_pool_internal.go +++ b/services/google/containerazure/beta/node_pool_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -391,20 +390,20 @@ func (op *deleteNodePoolOperation) do(ctx context.Context, r *NodePool, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetNodePool(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetNodePool(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/containerazure/cluster_internal.go b/services/google/containerazure/cluster_internal.go index 7232513c3..e446643a7 100755 --- a/services/google/containerazure/cluster_internal.go +++ b/services/google/containerazure/cluster_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -461,20 +460,20 @@ func (op *deleteClusterOperation) do(ctx context.Context, r *Cluster, c *Client) return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetCluster(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetCluster(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/containerazure/node_pool_internal.go b/services/google/containerazure/node_pool_internal.go index d8fde4115..3eb70b985 100755 --- a/services/google/containerazure/node_pool_internal.go +++ b/services/google/containerazure/node_pool_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -391,20 +390,20 @@ func (op *deleteNodePoolOperation) do(ctx context.Context, r *NodePool, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetNodePool(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetNodePool(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/datafusion/alpha/instance_internal.go b/services/google/datafusion/alpha/instance_internal.go index 1f86d4daa..f49b11b18 100755 --- a/services/google/datafusion/alpha/instance_internal.go +++ b/services/google/datafusion/alpha/instance_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -303,20 +302,20 @@ func (op *deleteInstanceOperation) do(ctx context.Context, r *Instance, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetInstance(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetInstance(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/datafusion/beta/instance_internal.go b/services/google/datafusion/beta/instance_internal.go index 46f7be383..d8b893692 100755 --- a/services/google/datafusion/beta/instance_internal.go +++ b/services/google/datafusion/beta/instance_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -303,20 +302,20 @@ func (op *deleteInstanceOperation) do(ctx context.Context, r *Instance, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetInstance(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetInstance(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dataplex/alpha/asset_internal.go b/services/google/dataplex/alpha/asset_internal.go index d8406ec7d..79c93ac9d 100755 --- a/services/google/dataplex/alpha/asset_internal.go +++ b/services/google/dataplex/alpha/asset_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -421,20 +420,20 @@ func (op *deleteAssetOperation) do(ctx context.Context, r *Asset, c *Client) err return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetAsset(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetAsset(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dataplex/alpha/lake_internal.go b/services/google/dataplex/alpha/lake_internal.go index c713ef0ee..816965f72 100755 --- a/services/google/dataplex/alpha/lake_internal.go +++ b/services/google/dataplex/alpha/lake_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -349,20 +348,20 @@ func (op *deleteLakeOperation) do(ctx context.Context, r *Lake, c *Client) error return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetLake(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetLake(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dataplex/alpha/zone_internal.go b/services/google/dataplex/alpha/zone_internal.go index f68a1c57c..20b9774c2 100755 --- a/services/google/dataplex/alpha/zone_internal.go +++ b/services/google/dataplex/alpha/zone_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -385,20 +384,20 @@ func (op *deleteZoneOperation) do(ctx context.Context, r *Zone, c *Client) error return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetZone(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetZone(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dataplex/asset_internal.go b/services/google/dataplex/asset_internal.go index 15dabbb5e..11594c493 100755 --- a/services/google/dataplex/asset_internal.go +++ b/services/google/dataplex/asset_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -421,20 +420,20 @@ func (op *deleteAssetOperation) do(ctx context.Context, r *Asset, c *Client) err return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetAsset(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetAsset(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dataplex/beta/asset_internal.go b/services/google/dataplex/beta/asset_internal.go index 2910bbcea..31a48c78c 100755 --- a/services/google/dataplex/beta/asset_internal.go +++ b/services/google/dataplex/beta/asset_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -421,20 +420,20 @@ func (op *deleteAssetOperation) do(ctx context.Context, r *Asset, c *Client) err return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetAsset(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetAsset(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dataplex/beta/lake_internal.go b/services/google/dataplex/beta/lake_internal.go index 00765c732..624445430 100755 --- a/services/google/dataplex/beta/lake_internal.go +++ b/services/google/dataplex/beta/lake_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -349,20 +348,20 @@ func (op *deleteLakeOperation) do(ctx context.Context, r *Lake, c *Client) error return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetLake(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetLake(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dataplex/beta/zone_internal.go b/services/google/dataplex/beta/zone_internal.go index e2e7e7232..1a01c5e6d 100755 --- a/services/google/dataplex/beta/zone_internal.go +++ b/services/google/dataplex/beta/zone_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -385,20 +384,20 @@ func (op *deleteZoneOperation) do(ctx context.Context, r *Zone, c *Client) error return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetZone(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetZone(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dataplex/lake_internal.go b/services/google/dataplex/lake_internal.go index a3eaa39e8..4ec6c38b1 100755 --- a/services/google/dataplex/lake_internal.go +++ b/services/google/dataplex/lake_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -349,20 +348,20 @@ func (op *deleteLakeOperation) do(ctx context.Context, r *Lake, c *Client) error return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetLake(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetLake(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dataplex/zone_internal.go b/services/google/dataplex/zone_internal.go index f3d94db8c..2d796f510 100755 --- a/services/google/dataplex/zone_internal.go +++ b/services/google/dataplex/zone_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -385,20 +384,20 @@ func (op *deleteZoneOperation) do(ctx context.Context, r *Zone, c *Client) error return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetZone(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetZone(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dataproc/alpha/autoscaling_policy_internal.go b/services/google/dataproc/alpha/autoscaling_policy_internal.go index ec5ed58c0..9425ffa6d 100755 --- a/services/google/dataproc/alpha/autoscaling_policy_internal.go +++ b/services/google/dataproc/alpha/autoscaling_policy_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -322,20 +321,20 @@ func (op *deleteAutoscalingPolicyOperation) do(ctx context.Context, r *Autoscali return fmt.Errorf("failed to delete AutoscalingPolicy: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetAutoscalingPolicy(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetAutoscalingPolicy(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dataproc/alpha/cluster_internal.go b/services/google/dataproc/alpha/cluster_internal.go index 15d18e526..fe61f6a42 100755 --- a/services/google/dataproc/alpha/cluster_internal.go +++ b/services/google/dataproc/alpha/cluster_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -528,20 +527,20 @@ func (op *deleteClusterOperation) do(ctx context.Context, r *Cluster, c *Client) return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetCluster(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetCluster(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dataproc/alpha/workflow_template_internal.go b/services/google/dataproc/alpha/workflow_template_internal.go index bc420c039..0b492caaa 100755 --- a/services/google/dataproc/alpha/workflow_template_internal.go +++ b/services/google/dataproc/alpha/workflow_template_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -653,20 +652,20 @@ func (op *deleteWorkflowTemplateOperation) do(ctx context.Context, r *WorkflowTe return fmt.Errorf("failed to delete WorkflowTemplate: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetWorkflowTemplate(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetWorkflowTemplate(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dataproc/autoscaling_policy_internal.go b/services/google/dataproc/autoscaling_policy_internal.go index 6380dfddc..cf667940f 100755 --- a/services/google/dataproc/autoscaling_policy_internal.go +++ b/services/google/dataproc/autoscaling_policy_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -322,20 +321,20 @@ func (op *deleteAutoscalingPolicyOperation) do(ctx context.Context, r *Autoscali return fmt.Errorf("failed to delete AutoscalingPolicy: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetAutoscalingPolicy(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetAutoscalingPolicy(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dataproc/beta/autoscaling_policy_internal.go b/services/google/dataproc/beta/autoscaling_policy_internal.go index a73833ca0..8b3ab09d5 100755 --- a/services/google/dataproc/beta/autoscaling_policy_internal.go +++ b/services/google/dataproc/beta/autoscaling_policy_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -322,20 +321,20 @@ func (op *deleteAutoscalingPolicyOperation) do(ctx context.Context, r *Autoscali return fmt.Errorf("failed to delete AutoscalingPolicy: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetAutoscalingPolicy(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetAutoscalingPolicy(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dataproc/beta/cluster_internal.go b/services/google/dataproc/beta/cluster_internal.go index ae5b95765..36a726b77 100755 --- a/services/google/dataproc/beta/cluster_internal.go +++ b/services/google/dataproc/beta/cluster_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -528,20 +527,20 @@ func (op *deleteClusterOperation) do(ctx context.Context, r *Cluster, c *Client) return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetCluster(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetCluster(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dataproc/beta/workflow_template_internal.go b/services/google/dataproc/beta/workflow_template_internal.go index dc2da8d1b..605432b7e 100755 --- a/services/google/dataproc/beta/workflow_template_internal.go +++ b/services/google/dataproc/beta/workflow_template_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -653,20 +652,20 @@ func (op *deleteWorkflowTemplateOperation) do(ctx context.Context, r *WorkflowTe return fmt.Errorf("failed to delete WorkflowTemplate: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetWorkflowTemplate(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetWorkflowTemplate(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dataproc/cluster_internal.go b/services/google/dataproc/cluster_internal.go index d346a7b26..7f676d196 100755 --- a/services/google/dataproc/cluster_internal.go +++ b/services/google/dataproc/cluster_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -501,20 +500,20 @@ func (op *deleteClusterOperation) do(ctx context.Context, r *Cluster, c *Client) return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetCluster(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetCluster(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dataproc/workflow_template_internal.go b/services/google/dataproc/workflow_template_internal.go index 7b6d94335..24febf9aa 100755 --- a/services/google/dataproc/workflow_template_internal.go +++ b/services/google/dataproc/workflow_template_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -626,20 +625,20 @@ func (op *deleteWorkflowTemplateOperation) do(ctx context.Context, r *WorkflowTe return fmt.Errorf("failed to delete WorkflowTemplate: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetWorkflowTemplate(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetWorkflowTemplate(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dlp/alpha/inspect_template_internal.go b/services/google/dlp/alpha/inspect_template_internal.go index ebb38a58e..2b33d737e 100755 --- a/services/google/dlp/alpha/inspect_template_internal.go +++ b/services/google/dlp/alpha/inspect_template_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -439,20 +438,20 @@ func (op *deleteInspectTemplateOperation) do(ctx context.Context, r *InspectTemp return fmt.Errorf("failed to delete InspectTemplate: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetInspectTemplate(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetInspectTemplate(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dlp/alpha/job_trigger_internal.go b/services/google/dlp/alpha/job_trigger_internal.go index 3980be42a..bdeef5561 100755 --- a/services/google/dlp/alpha/job_trigger_internal.go +++ b/services/google/dlp/alpha/job_trigger_internal.go @@ -13021,10 +13021,14 @@ func expandJobTriggerInspectJobStorageConfigBigQueryOptionsTableReference(c *Cli if v := f.ProjectId; !dcl.IsEmptyValueIndirect(v) { m["projectId"] = v } - if v := f.DatasetId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.DatasetId); err != nil { + return nil, fmt.Errorf("error expanding DatasetId into datasetId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["datasetId"] = v } - if v := f.TableId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.TableId); err != nil { + return nil, fmt.Errorf("error expanding TableId into tableId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["tableId"] = v } @@ -18333,13 +18337,19 @@ func expandJobTriggerInspectJobActionsSaveFindingsOutputConfigTable(c *Client, f } m := make(map[string]interface{}) - if v := f.ProjectId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.ProjectId); err != nil { + return nil, fmt.Errorf("error expanding ProjectId into projectId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["projectId"] = v } - if v := f.DatasetId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.DatasetId); err != nil { + return nil, fmt.Errorf("error expanding DatasetId into datasetId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["datasetId"] = v } - if v := f.TableId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.TableId); err != nil { + return nil, fmt.Errorf("error expanding TableId into tableId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["tableId"] = v } diff --git a/services/google/dlp/alpha/stored_info_type_internal.go b/services/google/dlp/alpha/stored_info_type_internal.go index d6a75798e..57b690d83 100755 --- a/services/google/dlp/alpha/stored_info_type_internal.go +++ b/services/google/dlp/alpha/stored_info_type_internal.go @@ -2938,13 +2938,19 @@ func expandStoredInfoTypeLargeCustomDictionaryBigQueryFieldTable(c *Client, f *S } m := make(map[string]interface{}) - if v := f.ProjectId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.ProjectId); err != nil { + return nil, fmt.Errorf("error expanding ProjectId into projectId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["projectId"] = v } - if v := f.DatasetId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.DatasetId); err != nil { + return nil, fmt.Errorf("error expanding DatasetId into datasetId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["datasetId"] = v } - if v := f.TableId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.TableId); err != nil { + return nil, fmt.Errorf("error expanding TableId into tableId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["tableId"] = v } diff --git a/services/google/dlp/beta/inspect_template_internal.go b/services/google/dlp/beta/inspect_template_internal.go index 7146161e1..19115a5ea 100755 --- a/services/google/dlp/beta/inspect_template_internal.go +++ b/services/google/dlp/beta/inspect_template_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -439,20 +438,20 @@ func (op *deleteInspectTemplateOperation) do(ctx context.Context, r *InspectTemp return fmt.Errorf("failed to delete InspectTemplate: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetInspectTemplate(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetInspectTemplate(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dlp/beta/job_trigger_internal.go b/services/google/dlp/beta/job_trigger_internal.go index 66a161f13..e13d3f01e 100755 --- a/services/google/dlp/beta/job_trigger_internal.go +++ b/services/google/dlp/beta/job_trigger_internal.go @@ -13021,10 +13021,14 @@ func expandJobTriggerInspectJobStorageConfigBigQueryOptionsTableReference(c *Cli if v := f.ProjectId; !dcl.IsEmptyValueIndirect(v) { m["projectId"] = v } - if v := f.DatasetId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.DatasetId); err != nil { + return nil, fmt.Errorf("error expanding DatasetId into datasetId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["datasetId"] = v } - if v := f.TableId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.TableId); err != nil { + return nil, fmt.Errorf("error expanding TableId into tableId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["tableId"] = v } @@ -18333,13 +18337,19 @@ func expandJobTriggerInspectJobActionsSaveFindingsOutputConfigTable(c *Client, f } m := make(map[string]interface{}) - if v := f.ProjectId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.ProjectId); err != nil { + return nil, fmt.Errorf("error expanding ProjectId into projectId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["projectId"] = v } - if v := f.DatasetId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.DatasetId); err != nil { + return nil, fmt.Errorf("error expanding DatasetId into datasetId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["datasetId"] = v } - if v := f.TableId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.TableId); err != nil { + return nil, fmt.Errorf("error expanding TableId into tableId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["tableId"] = v } diff --git a/services/google/dlp/beta/stored_info_type_internal.go b/services/google/dlp/beta/stored_info_type_internal.go index b83016053..7688bc4cd 100755 --- a/services/google/dlp/beta/stored_info_type_internal.go +++ b/services/google/dlp/beta/stored_info_type_internal.go @@ -2938,13 +2938,19 @@ func expandStoredInfoTypeLargeCustomDictionaryBigQueryFieldTable(c *Client, f *S } m := make(map[string]interface{}) - if v := f.ProjectId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.ProjectId); err != nil { + return nil, fmt.Errorf("error expanding ProjectId into projectId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["projectId"] = v } - if v := f.DatasetId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.DatasetId); err != nil { + return nil, fmt.Errorf("error expanding DatasetId into datasetId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["datasetId"] = v } - if v := f.TableId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.TableId); err != nil { + return nil, fmt.Errorf("error expanding TableId into tableId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["tableId"] = v } diff --git a/services/google/dlp/inspect_template_internal.go b/services/google/dlp/inspect_template_internal.go index dbe6f5c28..935b2957a 100755 --- a/services/google/dlp/inspect_template_internal.go +++ b/services/google/dlp/inspect_template_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -439,20 +438,20 @@ func (op *deleteInspectTemplateOperation) do(ctx context.Context, r *InspectTemp return fmt.Errorf("failed to delete InspectTemplate: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetInspectTemplate(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetInspectTemplate(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/dlp/job_trigger_internal.go b/services/google/dlp/job_trigger_internal.go index db9f6099b..f41cec425 100755 --- a/services/google/dlp/job_trigger_internal.go +++ b/services/google/dlp/job_trigger_internal.go @@ -13021,10 +13021,14 @@ func expandJobTriggerInspectJobStorageConfigBigQueryOptionsTableReference(c *Cli if v := f.ProjectId; !dcl.IsEmptyValueIndirect(v) { m["projectId"] = v } - if v := f.DatasetId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.DatasetId); err != nil { + return nil, fmt.Errorf("error expanding DatasetId into datasetId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["datasetId"] = v } - if v := f.TableId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.TableId); err != nil { + return nil, fmt.Errorf("error expanding TableId into tableId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["tableId"] = v } @@ -18333,13 +18337,19 @@ func expandJobTriggerInspectJobActionsSaveFindingsOutputConfigTable(c *Client, f } m := make(map[string]interface{}) - if v := f.ProjectId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.ProjectId); err != nil { + return nil, fmt.Errorf("error expanding ProjectId into projectId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["projectId"] = v } - if v := f.DatasetId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.DatasetId); err != nil { + return nil, fmt.Errorf("error expanding DatasetId into datasetId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["datasetId"] = v } - if v := f.TableId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.TableId); err != nil { + return nil, fmt.Errorf("error expanding TableId into tableId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["tableId"] = v } diff --git a/services/google/dlp/stored_info_type_internal.go b/services/google/dlp/stored_info_type_internal.go index 819d75424..c781f7b25 100755 --- a/services/google/dlp/stored_info_type_internal.go +++ b/services/google/dlp/stored_info_type_internal.go @@ -2938,13 +2938,19 @@ func expandStoredInfoTypeLargeCustomDictionaryBigQueryFieldTable(c *Client, f *S } m := make(map[string]interface{}) - if v := f.ProjectId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.ProjectId); err != nil { + return nil, fmt.Errorf("error expanding ProjectId into projectId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["projectId"] = v } - if v := f.DatasetId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.DatasetId); err != nil { + return nil, fmt.Errorf("error expanding DatasetId into datasetId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["datasetId"] = v } - if v := f.TableId; !dcl.IsEmptyValueIndirect(v) { + if v, err := dcl.SelfLinkToNameExpander(f.TableId); err != nil { + return nil, fmt.Errorf("error expanding TableId into tableId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { m["tableId"] = v } diff --git a/services/google/eventarc/alpha/trigger_internal.go b/services/google/eventarc/alpha/trigger_internal.go index b69b09004..6730904e1 100755 --- a/services/google/eventarc/alpha/trigger_internal.go +++ b/services/google/eventarc/alpha/trigger_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -383,20 +382,20 @@ func (op *deleteTriggerOperation) do(ctx context.Context, r *Trigger, c *Client) return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTrigger(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTrigger(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/eventarc/beta/trigger_internal.go b/services/google/eventarc/beta/trigger_internal.go index 1334d19a8..6f04b6053 100755 --- a/services/google/eventarc/beta/trigger_internal.go +++ b/services/google/eventarc/beta/trigger_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -383,20 +382,20 @@ func (op *deleteTriggerOperation) do(ctx context.Context, r *Trigger, c *Client) return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTrigger(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTrigger(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/eventarc/trigger_internal.go b/services/google/eventarc/trigger_internal.go index 1dfaf8802..b6ccff156 100755 --- a/services/google/eventarc/trigger_internal.go +++ b/services/google/eventarc/trigger_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -383,20 +382,20 @@ func (op *deleteTriggerOperation) do(ctx context.Context, r *Trigger, c *Client) return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTrigger(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTrigger(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/filestore/alpha/backup_internal.go b/services/google/filestore/alpha/backup_internal.go index 371527f49..ded034c6c 100755 --- a/services/google/filestore/alpha/backup_internal.go +++ b/services/google/filestore/alpha/backup_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -286,20 +285,20 @@ func (op *deleteBackupOperation) do(ctx context.Context, r *Backup, c *Client) e return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetBackup(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetBackup(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/filestore/alpha/instance_internal.go b/services/google/filestore/alpha/instance_internal.go index 4d52906b6..5dae02594 100755 --- a/services/google/filestore/alpha/instance_internal.go +++ b/services/google/filestore/alpha/instance_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -311,20 +310,20 @@ func (op *deleteInstanceOperation) do(ctx context.Context, r *Instance, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetInstance(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetInstance(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/filestore/beta/backup_internal.go b/services/google/filestore/beta/backup_internal.go index 79cad8746..9e180f449 100755 --- a/services/google/filestore/beta/backup_internal.go +++ b/services/google/filestore/beta/backup_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -286,20 +285,20 @@ func (op *deleteBackupOperation) do(ctx context.Context, r *Backup, c *Client) e return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetBackup(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetBackup(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/filestore/beta/instance_internal.go b/services/google/filestore/beta/instance_internal.go index 7a60bafa1..ddc33e3d0 100755 --- a/services/google/filestore/beta/instance_internal.go +++ b/services/google/filestore/beta/instance_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -311,20 +310,20 @@ func (op *deleteInstanceOperation) do(ctx context.Context, r *Instance, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetInstance(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetInstance(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/filestore/instance_internal.go b/services/google/filestore/instance_internal.go index e4dc4f2e3..285d301c8 100755 --- a/services/google/filestore/instance_internal.go +++ b/services/google/filestore/instance_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -311,20 +310,20 @@ func (op *deleteInstanceOperation) do(ctx context.Context, r *Instance, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetInstance(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetInstance(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/gameservices/alpha/realm_internal.go b/services/google/gameservices/alpha/realm_internal.go index 2e8994cd5..31b6319f7 100755 --- a/services/google/gameservices/alpha/realm_internal.go +++ b/services/google/gameservices/alpha/realm_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -283,20 +282,20 @@ func (op *deleteRealmOperation) do(ctx context.Context, r *Realm, c *Client) err return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetRealm(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetRealm(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/gameservices/beta/realm_internal.go b/services/google/gameservices/beta/realm_internal.go index 94e87e18a..54d3684de 100755 --- a/services/google/gameservices/beta/realm_internal.go +++ b/services/google/gameservices/beta/realm_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -283,20 +282,20 @@ func (op *deleteRealmOperation) do(ctx context.Context, r *Realm, c *Client) err return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetRealm(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetRealm(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/gameservices/realm_internal.go b/services/google/gameservices/realm_internal.go index bd2dd5cca..10cdba84f 100755 --- a/services/google/gameservices/realm_internal.go +++ b/services/google/gameservices/realm_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -283,20 +282,20 @@ func (op *deleteRealmOperation) do(ctx context.Context, r *Realm, c *Client) err return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetRealm(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetRealm(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/gkehub/alpha/feature_internal.go b/services/google/gkehub/alpha/feature_internal.go index 11d7241bf..c66682f1f 100755 --- a/services/google/gkehub/alpha/feature_internal.go +++ b/services/google/gkehub/alpha/feature_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -272,20 +271,20 @@ func (op *deleteFeatureOperation) do(ctx context.Context, r *Feature, c *Client) return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetFeature(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetFeature(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/gkehub/alpha/membership_internal.go b/services/google/gkehub/alpha/membership_internal.go index c29c8ed75..0b7b562d8 100755 --- a/services/google/gkehub/alpha/membership_internal.go +++ b/services/google/gkehub/alpha/membership_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -378,20 +377,20 @@ func (op *deleteMembershipOperation) do(ctx context.Context, r *Membership, c *C return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetMembership(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetMembership(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/gkehub/beta/feature_internal.go b/services/google/gkehub/beta/feature_internal.go index 33e25c611..f9b1505d1 100755 --- a/services/google/gkehub/beta/feature_internal.go +++ b/services/google/gkehub/beta/feature_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -237,20 +236,20 @@ func (op *deleteFeatureOperation) do(ctx context.Context, r *Feature, c *Client) return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetFeature(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetFeature(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/gkehub/beta/membership_internal.go b/services/google/gkehub/beta/membership_internal.go index e1a2ef111..4faa01ba3 100755 --- a/services/google/gkehub/beta/membership_internal.go +++ b/services/google/gkehub/beta/membership_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -378,20 +377,20 @@ func (op *deleteMembershipOperation) do(ctx context.Context, r *Membership, c *C return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetMembership(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetMembership(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/iam/alpha/service_account_internal.go b/services/google/iam/alpha/service_account_internal.go index 0a0ab53a3..ba0f21935 100755 --- a/services/google/iam/alpha/service_account_internal.go +++ b/services/google/iam/alpha/service_account_internal.go @@ -298,20 +298,20 @@ func (op *deleteServiceAccountOperation) do(ctx context.Context, r *ServiceAccou return fmt.Errorf("failed to delete ServiceAccount: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetServiceAccount(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetServiceAccount(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/iam/beta/service_account_internal.go b/services/google/iam/beta/service_account_internal.go index 065d70c6a..526e6fb74 100755 --- a/services/google/iam/beta/service_account_internal.go +++ b/services/google/iam/beta/service_account_internal.go @@ -298,20 +298,20 @@ func (op *deleteServiceAccountOperation) do(ctx context.Context, r *ServiceAccou return fmt.Errorf("failed to delete ServiceAccount: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetServiceAccount(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetServiceAccount(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/iam/service_account_internal.go b/services/google/iam/service_account_internal.go index b15b970d1..1fb154b2a 100755 --- a/services/google/iam/service_account_internal.go +++ b/services/google/iam/service_account_internal.go @@ -298,20 +298,20 @@ func (op *deleteServiceAccountOperation) do(ctx context.Context, r *ServiceAccou return fmt.Errorf("failed to delete ServiceAccount: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetServiceAccount(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetServiceAccount(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/iap/alpha/identity_aware_proxy_client_internal.go b/services/google/iap/alpha/identity_aware_proxy_client_internal.go index 01e9d9015..7171fbcb5 100755 --- a/services/google/iap/alpha/identity_aware_proxy_client_internal.go +++ b/services/google/iap/alpha/identity_aware_proxy_client_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -186,20 +185,20 @@ func (op *deleteIdentityAwareProxyClientOperation) do(ctx context.Context, r *Id return fmt.Errorf("failed to delete IdentityAwareProxyClient: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetIdentityAwareProxyClient(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetIdentityAwareProxyClient(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/iap/beta/identity_aware_proxy_client_internal.go b/services/google/iap/beta/identity_aware_proxy_client_internal.go index 983f5b336..6126fcfb0 100755 --- a/services/google/iap/beta/identity_aware_proxy_client_internal.go +++ b/services/google/iap/beta/identity_aware_proxy_client_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -186,20 +185,20 @@ func (op *deleteIdentityAwareProxyClientOperation) do(ctx context.Context, r *Id return fmt.Errorf("failed to delete IdentityAwareProxyClient: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetIdentityAwareProxyClient(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetIdentityAwareProxyClient(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/iap/identity_aware_proxy_client_internal.go b/services/google/iap/identity_aware_proxy_client_internal.go index fc4299786..bb2361a55 100755 --- a/services/google/iap/identity_aware_proxy_client_internal.go +++ b/services/google/iap/identity_aware_proxy_client_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -186,20 +185,20 @@ func (op *deleteIdentityAwareProxyClientOperation) do(ctx context.Context, r *Id return fmt.Errorf("failed to delete IdentityAwareProxyClient: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetIdentityAwareProxyClient(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetIdentityAwareProxyClient(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/identitytoolkit/alpha/oauth_idp_config_internal.go b/services/google/identitytoolkit/alpha/oauth_idp_config_internal.go index 5a0e22815..ee851358e 100755 --- a/services/google/identitytoolkit/alpha/oauth_idp_config_internal.go +++ b/services/google/identitytoolkit/alpha/oauth_idp_config_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -274,20 +273,20 @@ func (op *deleteOAuthIdpConfigOperation) do(ctx context.Context, r *OAuthIdpConf return fmt.Errorf("failed to delete OAuthIdpConfig: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetOAuthIdpConfig(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetOAuthIdpConfig(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/identitytoolkit/alpha/tenant_internal.go b/services/google/identitytoolkit/alpha/tenant_internal.go index 8ba5fc4b2..41434a0dd 100755 --- a/services/google/identitytoolkit/alpha/tenant_internal.go +++ b/services/google/identitytoolkit/alpha/tenant_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -268,20 +267,20 @@ func (op *deleteTenantOperation) do(ctx context.Context, r *Tenant, c *Client) e return fmt.Errorf("failed to delete Tenant: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTenant(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTenant(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/identitytoolkit/alpha/tenant_oauth_idp_config_internal.go b/services/google/identitytoolkit/alpha/tenant_oauth_idp_config_internal.go index 9226011e3..a12563539 100755 --- a/services/google/identitytoolkit/alpha/tenant_oauth_idp_config_internal.go +++ b/services/google/identitytoolkit/alpha/tenant_oauth_idp_config_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -282,20 +281,20 @@ func (op *deleteTenantOAuthIdpConfigOperation) do(ctx context.Context, r *Tenant return fmt.Errorf("failed to delete TenantOAuthIdpConfig: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTenantOAuthIdpConfig(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTenantOAuthIdpConfig(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/identitytoolkit/beta/oauth_idp_config_internal.go b/services/google/identitytoolkit/beta/oauth_idp_config_internal.go index 8c979b8ae..0619223ef 100755 --- a/services/google/identitytoolkit/beta/oauth_idp_config_internal.go +++ b/services/google/identitytoolkit/beta/oauth_idp_config_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -274,20 +273,20 @@ func (op *deleteOAuthIdpConfigOperation) do(ctx context.Context, r *OAuthIdpConf return fmt.Errorf("failed to delete OAuthIdpConfig: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetOAuthIdpConfig(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetOAuthIdpConfig(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/identitytoolkit/beta/tenant_internal.go b/services/google/identitytoolkit/beta/tenant_internal.go index f9acc38c6..ef8e303f4 100755 --- a/services/google/identitytoolkit/beta/tenant_internal.go +++ b/services/google/identitytoolkit/beta/tenant_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -268,20 +267,20 @@ func (op *deleteTenantOperation) do(ctx context.Context, r *Tenant, c *Client) e return fmt.Errorf("failed to delete Tenant: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTenant(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTenant(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/identitytoolkit/beta/tenant_oauth_idp_config_internal.go b/services/google/identitytoolkit/beta/tenant_oauth_idp_config_internal.go index 535d42519..b86a3d0e5 100755 --- a/services/google/identitytoolkit/beta/tenant_oauth_idp_config_internal.go +++ b/services/google/identitytoolkit/beta/tenant_oauth_idp_config_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -282,20 +281,20 @@ func (op *deleteTenantOAuthIdpConfigOperation) do(ctx context.Context, r *Tenant return fmt.Errorf("failed to delete TenantOAuthIdpConfig: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTenantOAuthIdpConfig(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTenantOAuthIdpConfig(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/identitytoolkit/oauth_idp_config_internal.go b/services/google/identitytoolkit/oauth_idp_config_internal.go index 6f8cd3fac..6f630f242 100755 --- a/services/google/identitytoolkit/oauth_idp_config_internal.go +++ b/services/google/identitytoolkit/oauth_idp_config_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -274,20 +273,20 @@ func (op *deleteOAuthIdpConfigOperation) do(ctx context.Context, r *OAuthIdpConf return fmt.Errorf("failed to delete OAuthIdpConfig: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetOAuthIdpConfig(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetOAuthIdpConfig(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/identitytoolkit/tenant_internal.go b/services/google/identitytoolkit/tenant_internal.go index 3d1dca917..ffbcd2d5b 100755 --- a/services/google/identitytoolkit/tenant_internal.go +++ b/services/google/identitytoolkit/tenant_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -268,20 +267,20 @@ func (op *deleteTenantOperation) do(ctx context.Context, r *Tenant, c *Client) e return fmt.Errorf("failed to delete Tenant: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTenant(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTenant(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/identitytoolkit/tenant_oauth_idp_config_internal.go b/services/google/identitytoolkit/tenant_oauth_idp_config_internal.go index 9420b78a5..c09f83a93 100755 --- a/services/google/identitytoolkit/tenant_oauth_idp_config_internal.go +++ b/services/google/identitytoolkit/tenant_oauth_idp_config_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -282,20 +281,20 @@ func (op *deleteTenantOAuthIdpConfigOperation) do(ctx context.Context, r *Tenant return fmt.Errorf("failed to delete TenantOAuthIdpConfig: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTenantOAuthIdpConfig(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTenantOAuthIdpConfig(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/logging/alpha/log_exclusion_internal.go b/services/google/logging/alpha/log_exclusion_internal.go index cf53aef89..eb4757293 100755 --- a/services/google/logging/alpha/log_exclusion_internal.go +++ b/services/google/logging/alpha/log_exclusion_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -254,20 +253,20 @@ func (op *deleteLogExclusionOperation) do(ctx context.Context, r *LogExclusion, return fmt.Errorf("failed to delete LogExclusion: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetLogExclusion(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetLogExclusion(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/logging/alpha/log_metric_internal.go b/services/google/logging/alpha/log_metric_internal.go index fc5fcdb56..bf4e5530b 100755 --- a/services/google/logging/alpha/log_metric_internal.go +++ b/services/google/logging/alpha/log_metric_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -322,20 +321,20 @@ func (op *deleteLogMetricOperation) do(ctx context.Context, r *LogMetric, c *Cli return fmt.Errorf("failed to delete LogMetric: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetLogMetric(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetLogMetric(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/logging/alpha/log_view_internal.go b/services/google/logging/alpha/log_view_internal.go index 6ae85e737..47c9420f0 100755 --- a/services/google/logging/alpha/log_view_internal.go +++ b/services/google/logging/alpha/log_view_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -262,20 +261,20 @@ func (op *deleteLogViewOperation) do(ctx context.Context, r *LogView, c *Client) return fmt.Errorf("failed to delete LogView: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetLogView(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetLogView(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/logging/beta/log_exclusion_internal.go b/services/google/logging/beta/log_exclusion_internal.go index 95237e1dc..752ed1873 100755 --- a/services/google/logging/beta/log_exclusion_internal.go +++ b/services/google/logging/beta/log_exclusion_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -254,20 +253,20 @@ func (op *deleteLogExclusionOperation) do(ctx context.Context, r *LogExclusion, return fmt.Errorf("failed to delete LogExclusion: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetLogExclusion(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetLogExclusion(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/logging/beta/log_metric_internal.go b/services/google/logging/beta/log_metric_internal.go index a2f6674c1..3bb1ed2fa 100755 --- a/services/google/logging/beta/log_metric_internal.go +++ b/services/google/logging/beta/log_metric_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -322,20 +321,20 @@ func (op *deleteLogMetricOperation) do(ctx context.Context, r *LogMetric, c *Cli return fmt.Errorf("failed to delete LogMetric: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetLogMetric(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetLogMetric(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/logging/beta/log_view_internal.go b/services/google/logging/beta/log_view_internal.go index 02dac2406..036ef2a21 100755 --- a/services/google/logging/beta/log_view_internal.go +++ b/services/google/logging/beta/log_view_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -262,20 +261,20 @@ func (op *deleteLogViewOperation) do(ctx context.Context, r *LogView, c *Client) return fmt.Errorf("failed to delete LogView: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetLogView(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetLogView(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/logging/log_exclusion_internal.go b/services/google/logging/log_exclusion_internal.go index e2d504df7..4cb0fed35 100755 --- a/services/google/logging/log_exclusion_internal.go +++ b/services/google/logging/log_exclusion_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -254,20 +253,20 @@ func (op *deleteLogExclusionOperation) do(ctx context.Context, r *LogExclusion, return fmt.Errorf("failed to delete LogExclusion: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetLogExclusion(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetLogExclusion(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/logging/log_metric_internal.go b/services/google/logging/log_metric_internal.go index 1c279fd77..cffd3ccf9 100755 --- a/services/google/logging/log_metric_internal.go +++ b/services/google/logging/log_metric_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -322,20 +321,20 @@ func (op *deleteLogMetricOperation) do(ctx context.Context, r *LogMetric, c *Cli return fmt.Errorf("failed to delete LogMetric: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetLogMetric(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetLogMetric(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/logging/log_view_internal.go b/services/google/logging/log_view_internal.go index dad59d5d5..aa7f4fde8 100755 --- a/services/google/logging/log_view_internal.go +++ b/services/google/logging/log_view_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -262,20 +261,20 @@ func (op *deleteLogViewOperation) do(ctx context.Context, r *LogView, c *Client) return fmt.Errorf("failed to delete LogView: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetLogView(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetLogView(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/monitoring/alpha/dashboard_internal.go b/services/google/monitoring/alpha/dashboard_internal.go index 6bb7b14a9..cd164272d 100755 --- a/services/google/monitoring/alpha/dashboard_internal.go +++ b/services/google/monitoring/alpha/dashboard_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -1602,20 +1601,20 @@ func (op *deleteDashboardOperation) do(ctx context.Context, r *Dashboard, c *Cli return fmt.Errorf("failed to delete Dashboard: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetDashboard(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetDashboard(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/monitoring/alpha/group_internal.go b/services/google/monitoring/alpha/group_internal.go index 4953a3f30..52c8b3ad9 100755 --- a/services/google/monitoring/alpha/group_internal.go +++ b/services/google/monitoring/alpha/group_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -257,20 +256,20 @@ func (op *deleteGroupOperation) do(ctx context.Context, r *Group, c *Client) err return fmt.Errorf("failed to delete Group: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetGroup(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetGroup(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/monitoring/alpha/metric_descriptor_internal.go b/services/google/monitoring/alpha/metric_descriptor_internal.go index c384d3c3d..7d2b179cb 100755 --- a/services/google/monitoring/alpha/metric_descriptor_internal.go +++ b/services/google/monitoring/alpha/metric_descriptor_internal.go @@ -198,20 +198,20 @@ func (op *deleteMetricDescriptorOperation) do(ctx context.Context, r *MetricDesc return fmt.Errorf("failed to delete MetricDescriptor: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetMetricDescriptor(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetMetricDescriptor(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/monitoring/alpha/monitored_project_internal.go b/services/google/monitoring/alpha/monitored_project_internal.go index cf138e942..973b285ec 100755 --- a/services/google/monitoring/alpha/monitored_project_internal.go +++ b/services/google/monitoring/alpha/monitored_project_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -190,20 +189,20 @@ func (op *deleteMonitoredProjectOperation) do(ctx context.Context, r *MonitoredP return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetMonitoredProject(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetMonitoredProject(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/monitoring/alpha/notification_channel_internal.go b/services/google/monitoring/alpha/notification_channel_internal.go index be98abe79..f72018d98 100755 --- a/services/google/monitoring/alpha/notification_channel_internal.go +++ b/services/google/monitoring/alpha/notification_channel_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -259,20 +258,20 @@ func (op *deleteNotificationChannelOperation) do(ctx context.Context, r *Notific return fmt.Errorf("failed to delete NotificationChannel: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetNotificationChannel(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetNotificationChannel(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/monitoring/alpha/uptime_check_config_internal.go b/services/google/monitoring/alpha/uptime_check_config_internal.go index d74927719..c2599f7a1 100755 --- a/services/google/monitoring/alpha/uptime_check_config_internal.go +++ b/services/google/monitoring/alpha/uptime_check_config_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -341,20 +340,20 @@ func (op *deleteUptimeCheckConfigOperation) do(ctx context.Context, r *UptimeChe return fmt.Errorf("failed to delete UptimeCheckConfig: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetUptimeCheckConfig(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetUptimeCheckConfig(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/monitoring/beta/dashboard_internal.go b/services/google/monitoring/beta/dashboard_internal.go index 9a4f160ec..c2fb64b1d 100755 --- a/services/google/monitoring/beta/dashboard_internal.go +++ b/services/google/monitoring/beta/dashboard_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -1602,20 +1601,20 @@ func (op *deleteDashboardOperation) do(ctx context.Context, r *Dashboard, c *Cli return fmt.Errorf("failed to delete Dashboard: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetDashboard(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetDashboard(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/monitoring/beta/group_internal.go b/services/google/monitoring/beta/group_internal.go index d7efc4a2f..864222167 100755 --- a/services/google/monitoring/beta/group_internal.go +++ b/services/google/monitoring/beta/group_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -257,20 +256,20 @@ func (op *deleteGroupOperation) do(ctx context.Context, r *Group, c *Client) err return fmt.Errorf("failed to delete Group: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetGroup(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetGroup(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/monitoring/beta/metric_descriptor_internal.go b/services/google/monitoring/beta/metric_descriptor_internal.go index 1008686a6..ce50e6f16 100755 --- a/services/google/monitoring/beta/metric_descriptor_internal.go +++ b/services/google/monitoring/beta/metric_descriptor_internal.go @@ -198,20 +198,20 @@ func (op *deleteMetricDescriptorOperation) do(ctx context.Context, r *MetricDesc return fmt.Errorf("failed to delete MetricDescriptor: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetMetricDescriptor(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetMetricDescriptor(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/monitoring/beta/monitored_project_internal.go b/services/google/monitoring/beta/monitored_project_internal.go index 419550836..b86791101 100755 --- a/services/google/monitoring/beta/monitored_project_internal.go +++ b/services/google/monitoring/beta/monitored_project_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -190,20 +189,20 @@ func (op *deleteMonitoredProjectOperation) do(ctx context.Context, r *MonitoredP return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetMonitoredProject(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetMonitoredProject(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/monitoring/beta/notification_channel_internal.go b/services/google/monitoring/beta/notification_channel_internal.go index 5690f5223..4cc726f6a 100755 --- a/services/google/monitoring/beta/notification_channel_internal.go +++ b/services/google/monitoring/beta/notification_channel_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -259,20 +258,20 @@ func (op *deleteNotificationChannelOperation) do(ctx context.Context, r *Notific return fmt.Errorf("failed to delete NotificationChannel: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetNotificationChannel(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetNotificationChannel(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/monitoring/beta/uptime_check_config_internal.go b/services/google/monitoring/beta/uptime_check_config_internal.go index 04c22b80d..6ee40ba49 100755 --- a/services/google/monitoring/beta/uptime_check_config_internal.go +++ b/services/google/monitoring/beta/uptime_check_config_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -341,20 +340,20 @@ func (op *deleteUptimeCheckConfigOperation) do(ctx context.Context, r *UptimeChe return fmt.Errorf("failed to delete UptimeCheckConfig: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetUptimeCheckConfig(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetUptimeCheckConfig(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/monitoring/dashboard_internal.go b/services/google/monitoring/dashboard_internal.go index c1ea421d4..c9dcd3963 100755 --- a/services/google/monitoring/dashboard_internal.go +++ b/services/google/monitoring/dashboard_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -1602,20 +1601,20 @@ func (op *deleteDashboardOperation) do(ctx context.Context, r *Dashboard, c *Cli return fmt.Errorf("failed to delete Dashboard: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetDashboard(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetDashboard(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/monitoring/group_internal.go b/services/google/monitoring/group_internal.go index c278ccb60..3a4ef4ac4 100755 --- a/services/google/monitoring/group_internal.go +++ b/services/google/monitoring/group_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -257,20 +256,20 @@ func (op *deleteGroupOperation) do(ctx context.Context, r *Group, c *Client) err return fmt.Errorf("failed to delete Group: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetGroup(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetGroup(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/monitoring/metric_descriptor_internal.go b/services/google/monitoring/metric_descriptor_internal.go index dc9db1cd5..e91903267 100755 --- a/services/google/monitoring/metric_descriptor_internal.go +++ b/services/google/monitoring/metric_descriptor_internal.go @@ -198,20 +198,20 @@ func (op *deleteMetricDescriptorOperation) do(ctx context.Context, r *MetricDesc return fmt.Errorf("failed to delete MetricDescriptor: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetMetricDescriptor(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetMetricDescriptor(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/monitoring/monitored_project_internal.go b/services/google/monitoring/monitored_project_internal.go index e64630d1c..65c88e4ff 100755 --- a/services/google/monitoring/monitored_project_internal.go +++ b/services/google/monitoring/monitored_project_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -190,20 +189,20 @@ func (op *deleteMonitoredProjectOperation) do(ctx context.Context, r *MonitoredP return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetMonitoredProject(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetMonitoredProject(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/monitoring/notification_channel_internal.go b/services/google/monitoring/notification_channel_internal.go index 0f62fba97..735748c85 100755 --- a/services/google/monitoring/notification_channel_internal.go +++ b/services/google/monitoring/notification_channel_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -259,20 +258,20 @@ func (op *deleteNotificationChannelOperation) do(ctx context.Context, r *Notific return fmt.Errorf("failed to delete NotificationChannel: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetNotificationChannel(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetNotificationChannel(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/monitoring/uptime_check_config_internal.go b/services/google/monitoring/uptime_check_config_internal.go index 05e3ed8c2..c980ae04e 100755 --- a/services/google/monitoring/uptime_check_config_internal.go +++ b/services/google/monitoring/uptime_check_config_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -341,20 +340,20 @@ func (op *deleteUptimeCheckConfigOperation) do(ctx context.Context, r *UptimeChe return fmt.Errorf("failed to delete UptimeCheckConfig: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetUptimeCheckConfig(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetUptimeCheckConfig(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkconnectivity/alpha/hub_internal.go b/services/google/networkconnectivity/alpha/hub_internal.go index a7126ed0e..d59d27fce 100755 --- a/services/google/networkconnectivity/alpha/hub_internal.go +++ b/services/google/networkconnectivity/alpha/hub_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -275,20 +274,20 @@ func (op *deleteHubOperation) do(ctx context.Context, r *Hub, c *Client) error { return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetHub(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetHub(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkconnectivity/alpha/spoke_internal.go b/services/google/networkconnectivity/alpha/spoke_internal.go index 4bed715bd..69fc973cc 100755 --- a/services/google/networkconnectivity/alpha/spoke_internal.go +++ b/services/google/networkconnectivity/alpha/spoke_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -331,20 +330,20 @@ func (op *deleteSpokeOperation) do(ctx context.Context, r *Spoke, c *Client) err return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetSpoke(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetSpoke(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkconnectivity/beta/hub_internal.go b/services/google/networkconnectivity/beta/hub_internal.go index a39428f77..ed9279ef7 100755 --- a/services/google/networkconnectivity/beta/hub_internal.go +++ b/services/google/networkconnectivity/beta/hub_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -275,20 +274,20 @@ func (op *deleteHubOperation) do(ctx context.Context, r *Hub, c *Client) error { return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetHub(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetHub(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkconnectivity/beta/spoke_internal.go b/services/google/networkconnectivity/beta/spoke_internal.go index 585daddbc..43882829e 100755 --- a/services/google/networkconnectivity/beta/spoke_internal.go +++ b/services/google/networkconnectivity/beta/spoke_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -331,20 +330,20 @@ func (op *deleteSpokeOperation) do(ctx context.Context, r *Spoke, c *Client) err return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetSpoke(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetSpoke(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkconnectivity/hub_internal.go b/services/google/networkconnectivity/hub_internal.go index 532656fc8..250536ad2 100755 --- a/services/google/networkconnectivity/hub_internal.go +++ b/services/google/networkconnectivity/hub_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -275,20 +274,20 @@ func (op *deleteHubOperation) do(ctx context.Context, r *Hub, c *Client) error { return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetHub(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetHub(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkconnectivity/spoke_internal.go b/services/google/networkconnectivity/spoke_internal.go index 7349cee15..c97873ad8 100755 --- a/services/google/networkconnectivity/spoke_internal.go +++ b/services/google/networkconnectivity/spoke_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -331,20 +330,20 @@ func (op *deleteSpokeOperation) do(ctx context.Context, r *Spoke, c *Client) err return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetSpoke(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetSpoke(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networksecurity/alpha/authorization_policy_internal.go b/services/google/networksecurity/alpha/authorization_policy_internal.go index e11549a50..0a67f4e2a 100755 --- a/services/google/networksecurity/alpha/authorization_policy_internal.go +++ b/services/google/networksecurity/alpha/authorization_policy_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -343,20 +342,20 @@ func (op *deleteAuthorizationPolicyOperation) do(ctx context.Context, r *Authori return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetAuthorizationPolicy(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetAuthorizationPolicy(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networksecurity/alpha/client_tls_policy_internal.go b/services/google/networksecurity/alpha/client_tls_policy_internal.go index d19fbcefb..3b0017381 100755 --- a/services/google/networksecurity/alpha/client_tls_policy_internal.go +++ b/services/google/networksecurity/alpha/client_tls_policy_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -391,20 +390,20 @@ func (op *deleteClientTlsPolicyOperation) do(ctx context.Context, r *ClientTlsPo return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetClientTlsPolicy(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetClientTlsPolicy(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networksecurity/alpha/server_tls_policy_internal.go b/services/google/networksecurity/alpha/server_tls_policy_internal.go index 6d2d5f9e4..ef4edb79b 100755 --- a/services/google/networksecurity/alpha/server_tls_policy_internal.go +++ b/services/google/networksecurity/alpha/server_tls_policy_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -402,20 +401,20 @@ func (op *deleteServerTlsPolicyOperation) do(ctx context.Context, r *ServerTlsPo return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetServerTlsPolicy(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetServerTlsPolicy(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networksecurity/beta/authorization_policy_internal.go b/services/google/networksecurity/beta/authorization_policy_internal.go index 9e9a1d39a..118cbdc4f 100755 --- a/services/google/networksecurity/beta/authorization_policy_internal.go +++ b/services/google/networksecurity/beta/authorization_policy_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -343,20 +342,20 @@ func (op *deleteAuthorizationPolicyOperation) do(ctx context.Context, r *Authori return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetAuthorizationPolicy(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetAuthorizationPolicy(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networksecurity/beta/client_tls_policy_internal.go b/services/google/networksecurity/beta/client_tls_policy_internal.go index 23c779307..c718c45b5 100755 --- a/services/google/networksecurity/beta/client_tls_policy_internal.go +++ b/services/google/networksecurity/beta/client_tls_policy_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -377,20 +376,20 @@ func (op *deleteClientTlsPolicyOperation) do(ctx context.Context, r *ClientTlsPo return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetClientTlsPolicy(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetClientTlsPolicy(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networksecurity/beta/server_tls_policy_internal.go b/services/google/networksecurity/beta/server_tls_policy_internal.go index 3aecd5cda..29f53aa2b 100755 --- a/services/google/networksecurity/beta/server_tls_policy_internal.go +++ b/services/google/networksecurity/beta/server_tls_policy_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -388,20 +387,20 @@ func (op *deleteServerTlsPolicyOperation) do(ctx context.Context, r *ServerTlsPo return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetServerTlsPolicy(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetServerTlsPolicy(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkservices/alpha/endpoint_policy_internal.go b/services/google/networkservices/alpha/endpoint_policy_internal.go index 5b23b1d1e..c178c8f2b 100755 --- a/services/google/networkservices/alpha/endpoint_policy_internal.go +++ b/services/google/networkservices/alpha/endpoint_policy_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -336,20 +335,20 @@ func (op *deleteEndpointPolicyOperation) do(ctx context.Context, r *EndpointPoli return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetEndpointPolicy(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetEndpointPolicy(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkservices/alpha/gateway_internal.go b/services/google/networkservices/alpha/gateway_internal.go index d7fe41657..50d0d4259 100755 --- a/services/google/networkservices/alpha/gateway_internal.go +++ b/services/google/networkservices/alpha/gateway_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -325,20 +324,20 @@ func (op *deleteGatewayOperation) do(ctx context.Context, r *Gateway, c *Client) return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetGateway(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetGateway(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkservices/alpha/grpc_route_internal.go b/services/google/networkservices/alpha/grpc_route_internal.go index f627e03fd..6871eedec 100755 --- a/services/google/networkservices/alpha/grpc_route_internal.go +++ b/services/google/networkservices/alpha/grpc_route_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -435,20 +434,20 @@ func (op *deleteGrpcRouteOperation) do(ctx context.Context, r *GrpcRoute, c *Cli return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetGrpcRoute(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetGrpcRoute(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkservices/alpha/http_filter_internal.go b/services/google/networkservices/alpha/http_filter_internal.go index 2772706de..d0466d206 100755 --- a/services/google/networkservices/alpha/http_filter_internal.go +++ b/services/google/networkservices/alpha/http_filter_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -303,20 +302,20 @@ func (op *deleteHttpFilterOperation) do(ctx context.Context, r *HttpFilter, c *C return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetHttpFilter(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetHttpFilter(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkservices/alpha/http_route_internal.go b/services/google/networkservices/alpha/http_route_internal.go index 13ad48b8a..8d88827c3 100755 --- a/services/google/networkservices/alpha/http_route_internal.go +++ b/services/google/networkservices/alpha/http_route_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -458,20 +457,20 @@ func (op *deleteHttpRouteOperation) do(ctx context.Context, r *HttpRoute, c *Cli return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetHttpRoute(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetHttpRoute(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkservices/alpha/mesh_internal.go b/services/google/networkservices/alpha/mesh_internal.go index 29ce12672..81d98c5b7 100755 --- a/services/google/networkservices/alpha/mesh_internal.go +++ b/services/google/networkservices/alpha/mesh_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -310,20 +309,20 @@ func (op *deleteMeshOperation) do(ctx context.Context, r *Mesh, c *Client) error return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetMesh(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetMesh(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkservices/alpha/service_binding_internal.go b/services/google/networkservices/alpha/service_binding_internal.go index 66a6390d5..330245a5d 100755 --- a/services/google/networkservices/alpha/service_binding_internal.go +++ b/services/google/networkservices/alpha/service_binding_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -203,20 +202,20 @@ func (op *deleteServiceBindingOperation) do(ctx context.Context, r *ServiceBindi return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetServiceBinding(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetServiceBinding(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkservices/alpha/tcp_route_internal.go b/services/google/networkservices/alpha/tcp_route_internal.go index 625f6f482..7ff5d1def 100755 --- a/services/google/networkservices/alpha/tcp_route_internal.go +++ b/services/google/networkservices/alpha/tcp_route_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -350,20 +349,20 @@ func (op *deleteTcpRouteOperation) do(ctx context.Context, r *TcpRoute, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTcpRoute(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTcpRoute(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkservices/alpha/tls_route_internal.go b/services/google/networkservices/alpha/tls_route_internal.go index 9fd41d28c..d0ba92ada 100755 --- a/services/google/networkservices/alpha/tls_route_internal.go +++ b/services/google/networkservices/alpha/tls_route_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -347,20 +346,20 @@ func (op *deleteTlsRouteOperation) do(ctx context.Context, r *TlsRoute, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTlsRoute(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTlsRoute(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkservices/beta/endpoint_policy_internal.go b/services/google/networkservices/beta/endpoint_policy_internal.go index deb8c074f..655bb38a3 100755 --- a/services/google/networkservices/beta/endpoint_policy_internal.go +++ b/services/google/networkservices/beta/endpoint_policy_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -336,20 +335,20 @@ func (op *deleteEndpointPolicyOperation) do(ctx context.Context, r *EndpointPoli return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetEndpointPolicy(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetEndpointPolicy(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkservices/beta/gateway_internal.go b/services/google/networkservices/beta/gateway_internal.go index a1c98930a..461da56cc 100755 --- a/services/google/networkservices/beta/gateway_internal.go +++ b/services/google/networkservices/beta/gateway_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -325,20 +324,20 @@ func (op *deleteGatewayOperation) do(ctx context.Context, r *Gateway, c *Client) return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetGateway(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetGateway(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkservices/beta/grpc_route_internal.go b/services/google/networkservices/beta/grpc_route_internal.go index 6a0be883d..6731c90cb 100755 --- a/services/google/networkservices/beta/grpc_route_internal.go +++ b/services/google/networkservices/beta/grpc_route_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -435,20 +434,20 @@ func (op *deleteGrpcRouteOperation) do(ctx context.Context, r *GrpcRoute, c *Cli return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetGrpcRoute(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetGrpcRoute(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkservices/beta/http_route_internal.go b/services/google/networkservices/beta/http_route_internal.go index f28c88c23..15b2534ab 100755 --- a/services/google/networkservices/beta/http_route_internal.go +++ b/services/google/networkservices/beta/http_route_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -458,20 +457,20 @@ func (op *deleteHttpRouteOperation) do(ctx context.Context, r *HttpRoute, c *Cli return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetHttpRoute(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetHttpRoute(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkservices/beta/mesh_internal.go b/services/google/networkservices/beta/mesh_internal.go index 5b5161898..3409e5a1c 100755 --- a/services/google/networkservices/beta/mesh_internal.go +++ b/services/google/networkservices/beta/mesh_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -310,20 +309,20 @@ func (op *deleteMeshOperation) do(ctx context.Context, r *Mesh, c *Client) error return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetMesh(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetMesh(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkservices/beta/service_binding_internal.go b/services/google/networkservices/beta/service_binding_internal.go index 99a2ae183..799145a26 100755 --- a/services/google/networkservices/beta/service_binding_internal.go +++ b/services/google/networkservices/beta/service_binding_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -203,20 +202,20 @@ func (op *deleteServiceBindingOperation) do(ctx context.Context, r *ServiceBindi return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetServiceBinding(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetServiceBinding(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkservices/beta/tcp_route_internal.go b/services/google/networkservices/beta/tcp_route_internal.go index c4d75eab8..76f4d396d 100755 --- a/services/google/networkservices/beta/tcp_route_internal.go +++ b/services/google/networkservices/beta/tcp_route_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -350,20 +349,20 @@ func (op *deleteTcpRouteOperation) do(ctx context.Context, r *TcpRoute, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTcpRoute(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTcpRoute(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/networkservices/beta/tls_route_internal.go b/services/google/networkservices/beta/tls_route_internal.go index 864845e92..1f6b49c9e 100755 --- a/services/google/networkservices/beta/tls_route_internal.go +++ b/services/google/networkservices/beta/tls_route_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -347,20 +346,20 @@ func (op *deleteTlsRouteOperation) do(ctx context.Context, r *TlsRoute, c *Clien return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTlsRoute(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTlsRoute(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/osconfig/alpha/guest_policy_internal.go b/services/google/osconfig/alpha/guest_policy_internal.go index edb958470..78660cca1 100755 --- a/services/google/osconfig/alpha/guest_policy_internal.go +++ b/services/google/osconfig/alpha/guest_policy_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -506,20 +505,20 @@ func (op *deleteGuestPolicyOperation) do(ctx context.Context, r *GuestPolicy, c return fmt.Errorf("failed to delete GuestPolicy: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetGuestPolicy(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetGuestPolicy(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/osconfig/alpha/os_policy_assignment_internal.go b/services/google/osconfig/alpha/os_policy_assignment_internal.go index 4323a6708..c49898a8a 100755 --- a/services/google/osconfig/alpha/os_policy_assignment_internal.go +++ b/services/google/osconfig/alpha/os_policy_assignment_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -836,20 +835,20 @@ func (op *deleteOSPolicyAssignmentOperation) do(ctx context.Context, r *OSPolicy return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetOSPolicyAssignment(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetOSPolicyAssignment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/osconfig/beta/guest_policy_internal.go b/services/google/osconfig/beta/guest_policy_internal.go index 0ee301628..57b9df758 100755 --- a/services/google/osconfig/beta/guest_policy_internal.go +++ b/services/google/osconfig/beta/guest_policy_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -506,20 +505,20 @@ func (op *deleteGuestPolicyOperation) do(ctx context.Context, r *GuestPolicy, c return fmt.Errorf("failed to delete GuestPolicy: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetGuestPolicy(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetGuestPolicy(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/osconfig/beta/os_policy_assignment_internal.go b/services/google/osconfig/beta/os_policy_assignment_internal.go index edd644d5c..598a7c942 100755 --- a/services/google/osconfig/beta/os_policy_assignment_internal.go +++ b/services/google/osconfig/beta/os_policy_assignment_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -836,20 +835,20 @@ func (op *deleteOSPolicyAssignmentOperation) do(ctx context.Context, r *OSPolicy return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetOSPolicyAssignment(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetOSPolicyAssignment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/osconfig/os_policy_assignment_internal.go b/services/google/osconfig/os_policy_assignment_internal.go index eab2332b5..65accfa54 100755 --- a/services/google/osconfig/os_policy_assignment_internal.go +++ b/services/google/osconfig/os_policy_assignment_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -836,20 +835,20 @@ func (op *deleteOSPolicyAssignmentOperation) do(ctx context.Context, r *OSPolicy return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetOSPolicyAssignment(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetOSPolicyAssignment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/privateca/alpha/ca_pool_internal.go b/services/google/privateca/alpha/ca_pool_internal.go index b8b716561..926fb7b90 100755 --- a/services/google/privateca/alpha/ca_pool_internal.go +++ b/services/google/privateca/alpha/ca_pool_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -446,20 +445,20 @@ func (op *deleteCaPoolOperation) do(ctx context.Context, r *CaPool, c *Client) e return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetCaPool(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetCaPool(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/privateca/alpha/certificate_template_internal.go b/services/google/privateca/alpha/certificate_template_internal.go index be7d0436c..ac151aa7a 100755 --- a/services/google/privateca/alpha/certificate_template_internal.go +++ b/services/google/privateca/alpha/certificate_template_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -405,20 +404,20 @@ func (op *deleteCertificateTemplateOperation) do(ctx context.Context, r *Certifi return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetCertificateTemplate(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetCertificateTemplate(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/privateca/beta/ca_pool_internal.go b/services/google/privateca/beta/ca_pool_internal.go index 15fcdcf0c..76e0b7f15 100755 --- a/services/google/privateca/beta/ca_pool_internal.go +++ b/services/google/privateca/beta/ca_pool_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -446,20 +445,20 @@ func (op *deleteCaPoolOperation) do(ctx context.Context, r *CaPool, c *Client) e return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetCaPool(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetCaPool(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/privateca/beta/certificate_template_internal.go b/services/google/privateca/beta/certificate_template_internal.go index 16ca70ba9..2df61c4d8 100755 --- a/services/google/privateca/beta/certificate_template_internal.go +++ b/services/google/privateca/beta/certificate_template_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -405,20 +404,20 @@ func (op *deleteCertificateTemplateOperation) do(ctx context.Context, r *Certifi return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetCertificateTemplate(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetCertificateTemplate(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/privateca/ca_pool_internal.go b/services/google/privateca/ca_pool_internal.go index dff95f9ab..3f22ebcab 100755 --- a/services/google/privateca/ca_pool_internal.go +++ b/services/google/privateca/ca_pool_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -446,20 +445,20 @@ func (op *deleteCaPoolOperation) do(ctx context.Context, r *CaPool, c *Client) e return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetCaPool(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetCaPool(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/privateca/certificate_template_internal.go b/services/google/privateca/certificate_template_internal.go index e86edb8ec..d62f5105b 100755 --- a/services/google/privateca/certificate_template_internal.go +++ b/services/google/privateca/certificate_template_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -405,20 +404,20 @@ func (op *deleteCertificateTemplateOperation) do(ctx context.Context, r *Certifi return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetCertificateTemplate(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetCertificateTemplate(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/pubsub/alpha/topic_internal.go b/services/google/pubsub/alpha/topic_internal.go index 8ac46e464..b55e490eb 100755 --- a/services/google/pubsub/alpha/topic_internal.go +++ b/services/google/pubsub/alpha/topic_internal.go @@ -266,20 +266,20 @@ func (op *deleteTopicOperation) do(ctx context.Context, r *Topic, c *Client) err return fmt.Errorf("failed to delete Topic: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTopic(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTopic(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/pubsub/beta/topic_internal.go b/services/google/pubsub/beta/topic_internal.go index 2dcdb99d2..de72925d9 100755 --- a/services/google/pubsub/beta/topic_internal.go +++ b/services/google/pubsub/beta/topic_internal.go @@ -266,20 +266,20 @@ func (op *deleteTopicOperation) do(ctx context.Context, r *Topic, c *Client) err return fmt.Errorf("failed to delete Topic: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTopic(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTopic(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/pubsub/topic_internal.go b/services/google/pubsub/topic_internal.go index 435db2291..8374611aa 100755 --- a/services/google/pubsub/topic_internal.go +++ b/services/google/pubsub/topic_internal.go @@ -266,20 +266,20 @@ func (op *deleteTopicOperation) do(ctx context.Context, r *Topic, c *Client) err return fmt.Errorf("failed to delete Topic: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetTopic(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetTopic(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/storage/alpha/bucket_internal.go b/services/google/storage/alpha/bucket_internal.go index 78d9a7721..a59f1130e 100755 --- a/services/google/storage/alpha/bucket_internal.go +++ b/services/google/storage/alpha/bucket_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -349,20 +348,20 @@ func (op *deleteBucketOperation) do(ctx context.Context, r *Bucket, c *Client) e return fmt.Errorf("failed to delete Bucket: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetBucket(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetBucket(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/storage/beta/bucket_internal.go b/services/google/storage/beta/bucket_internal.go index dd86f248e..58c66a9b3 100755 --- a/services/google/storage/beta/bucket_internal.go +++ b/services/google/storage/beta/bucket_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -349,20 +348,20 @@ func (op *deleteBucketOperation) do(ctx context.Context, r *Bucket, c *Client) e return fmt.Errorf("failed to delete Bucket: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetBucket(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetBucket(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/storage/bucket_internal.go b/services/google/storage/bucket_internal.go index 886653681..c390d281e 100755 --- a/services/google/storage/bucket_internal.go +++ b/services/google/storage/bucket_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" ) @@ -349,20 +348,20 @@ func (op *deleteBucketOperation) do(ctx context.Context, r *Bucket, c *Client) e return fmt.Errorf("failed to delete Bucket: %w", err) } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetBucket(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetBucket(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/vmware/alpha/cluster_internal.go b/services/google/vmware/alpha/cluster_internal.go index 92a742c9f..dcecdef48 100755 --- a/services/google/vmware/alpha/cluster_internal.go +++ b/services/google/vmware/alpha/cluster_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -296,20 +295,20 @@ func (op *deleteClusterOperation) do(ctx context.Context, r *Cluster, c *Client) return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetCluster(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetCluster(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/vpcaccess/alpha/connector_internal.go b/services/google/vpcaccess/alpha/connector_internal.go index b9b1df522..15b106647 100755 --- a/services/google/vpcaccess/alpha/connector_internal.go +++ b/services/google/vpcaccess/alpha/connector_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -208,20 +207,20 @@ func (op *deleteConnectorOperation) do(ctx context.Context, r *Connector, c *Cli return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetConnector(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetConnector(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/vpcaccess/beta/connector_internal.go b/services/google/vpcaccess/beta/connector_internal.go index 81f48bbaa..aa0228fda 100755 --- a/services/google/vpcaccess/beta/connector_internal.go +++ b/services/google/vpcaccess/beta/connector_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -208,20 +207,20 @@ func (op *deleteConnectorOperation) do(ctx context.Context, r *Connector, c *Cli return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetConnector(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetConnector(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil } diff --git a/services/google/vpcaccess/connector_internal.go b/services/google/vpcaccess/connector_internal.go index 5a154ff58..e65500b0a 100755 --- a/services/google/vpcaccess/connector_internal.go +++ b/services/google/vpcaccess/connector_internal.go @@ -20,7 +20,6 @@ import ( "fmt" "io/ioutil" "strings" - "time" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" @@ -208,20 +207,20 @@ func (op *deleteConnectorOperation) do(ctx context.Context, r *Connector, c *Cli return err } - // we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. - // this is the reason we are adding retry to handle that case. - maxRetry := 10 - for i := 1; i <= maxRetry; i++ { - _, err = c.GetConnector(ctx, r) - if !dcl.IsNotFound(err) { - if i == maxRetry { - return dcl.NotDeletedError{ExistingResource: r} - } - time.Sleep(1000 * time.Millisecond) - } else { - break + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetConnector(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil } - } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) return nil }