Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error retry predicate for monitoring 409 error #2845

Merged
merged 3 commits into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, ""
}