From 93359f5875c34149a4903c85779228653681dab2 Mon Sep 17 00:00:00 2001 From: emily Date: Tue, 17 Dec 2019 13:41:11 -0800 Subject: [PATCH] Add error retry predicate for monitoring 409 error (#2845) Merged PR #2845. --- build/terraform | 2 +- build/terraform-beta | 2 +- products/monitoring/terraform.yaml | 5 +++++ third_party/terraform/utils/error_retry_predicates.go | 9 +++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/build/terraform b/build/terraform index a1d5f2ad6dda..b153307c1ef7 160000 --- a/build/terraform +++ b/build/terraform @@ -1 +1 @@ -Subproject commit a1d5f2ad6dda978a0faab302dcab6748548a278c +Subproject commit b153307c1ef799d90eb1f5636dc923790155a769 diff --git a/build/terraform-beta b/build/terraform-beta index 6e779d089e19..aa06b7c4b667 160000 --- a/build/terraform-beta +++ b/build/terraform-beta @@ -1 +1 @@ -Subproject commit 6e779d089e19f5c7c19a2229b5be05c667a8dcbc +Subproject commit aa06b7c4b66743fb6b949e364e45ef1ca150e3be diff --git a/products/monitoring/terraform.yaml b/products/monitoring/terraform.yaml index c33215edf71d..9f84b198c46c 100644 --- a/products/monitoring/terraform.yaml +++ b/products/monitoring/terraform.yaml @@ -16,6 +16,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides id_format: "{{name}}" import_format: ["{{name}}"] mutex: alertPolicy/{{project}} + error_retry_predicates: ["isMonitoringRetryableError"] examples: - !ruby/object:Provider::Terraform::Examples # skipping tests because the API is full of race conditions @@ -28,10 +29,12 @@ overrides: !ruby/object:Overrides::ResourceOverrides custom_import: templates/terraform/custom_import/self_link_as_name.erb post_create: templates/terraform/post_create/set_computed_name.erb extra_schema_entry: templates/terraform/extra_schema_entry/alert_policy.erb + Group: !ruby/object:Overrides::Terraform::ResourceOverride id_format: "{{name}}" import_format: ["{{name}}"] mutex: stackdriver/groups/{{project}} + error_retry_predicates: ["isMonitoringRetryableError"] examples: - !ruby/object:Provider::Terraform::Examples name: "monitoring_group_basic" @@ -55,6 +58,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides id_format: "{{name}}" import_format: ["{{name}}"] mutex: stackdriver/notifications/{{project}} + error_retry_predicates: ["isMonitoringRetryableError"] examples: - !ruby/object:Provider::Terraform::Examples name: "notification_channel_basic" @@ -85,6 +89,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides UptimeCheckConfig: !ruby/object:Overrides::Terraform::ResourceOverride id_format: "{{name}}" import_format: ["{{name}}"] + error_retry_predicates: ["isMonitoringRetryableError"] examples: - !ruby/object:Provider::Terraform::Examples name: "uptime_check_config_http" diff --git a/third_party/terraform/utils/error_retry_predicates.go b/third_party/terraform/utils/error_retry_predicates.go index c5d02726fc45..0cc2c1785234 100644 --- a/third_party/terraform/utils/error_retry_predicates.go +++ b/third_party/terraform/utils/error_retry_predicates.go @@ -41,3 +41,12 @@ func isSqlOperationInProgressError(err error) (bool, string) { } return false, "" } + +func isMonitoringRetryableError(err error) (bool, string) { + if gerr, ok := err.(*googleapi.Error); ok { + if gerr.Code == 409 && strings.Contains(strings.ToLower(gerr.Body), "too many concurrent edits") { + return true, "Waiting for other Monitoring changes to finish" + } + } + return false, "" +}