Skip to content

Commit

Permalink
Add error retry predicate for monitoring 409 error (#2845)
Browse files Browse the repository at this point in the history
Merged PR #2845.
  • Loading branch information
emilymye authored and modular-magician committed Dec 17, 2019
1 parent f3b37e5 commit 93359f5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build/terraform
2 changes: 1 addition & 1 deletion build/terraform-beta
5 changes: 5 additions & 0 deletions products/monitoring/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
9 changes: 9 additions & 0 deletions third_party/terraform/utils/error_retry_predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, ""
}

0 comments on commit 93359f5

Please sign in to comment.