Skip to content

Commit

Permalink
Add compute_route retry for "peering operation in progress"
Browse files Browse the repository at this point in the history
  • Loading branch information
c2thorn committed May 15, 2020
1 parent 11b8d2f commit c134d10
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1680,6 +1680,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides
Route: !ruby/object:Overrides::Terraform::ResourceOverride
# Route cannot be added while a peering is on progress on the network
mutex: 'projects/{{project}}/global/networks/{{network}}/peerings'
error_retry_predicates: ["isPeeringOperationInProgress"]
examples:
- !ruby/object:Provider::Terraform::Examples
name: "route_basic"
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 @@ -248,3 +248,12 @@ func isDataflowJobUpdateRetryableError(err error) (bool, string) {
}
return false, ""
}

func isPeeringOperationInProgress(err error) (bool, string) {
if gerr, ok := err.(*googleapi.Error); ok {
if gerr.Code == 400 && strings.Contains(gerr.Body, "There is a peering operation in progress") {
return true, "Waiting peering operation to complete"
}
}
return false, ""
}

0 comments on commit c134d10

Please sign in to comment.