Skip to content

Commit

Permalink
Add operation retry for exceeded quota group OperationReadGroup (#4599)…
Browse files Browse the repository at this point in the history
… (#8746)

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Mar 22, 2021
1 parent b2ec90e commit d6e2794
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/4599.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
compute: fixed an issue where exceeding the operation rate limit would fail without retrying
```
2 changes: 1 addition & 1 deletion google/common_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func CommonRefreshFunc(w Waiter) resource.StateRefreshFunc {
op, err := w.QueryOp()
if err != nil {
// Retry 404 when getting operation (not resource state)
if isRetryableError(err, isNotFoundRetryableError("GET operation")) {
if isRetryableError(err, isNotFoundRetryableError("GET operation"), isOperationReadQuotaError) {
log.Printf("[DEBUG] Dismissed retryable error on GET operation %q: %s", w.OpName(), err)
return nil, "done: false", nil
}
Expand Down
11 changes: 11 additions & 0 deletions google/error_retry_predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,17 @@ func isBigqueryIAMQuotaError(err error) (bool, string) {
return false, ""
}

// Retry if operation returns a 403 with the message for
// exceeding the quota limit for 'OperationReadGroup'
func isOperationReadQuotaError(err error) (bool, string) {
if gerr, ok := err.(*googleapi.Error); ok {
if gerr.Code == 403 && strings.Contains(gerr.Body, "Quota exceeded for quota group 'OperationReadGroup'") {
return true, "Waiting for quota to refresh"
}
}
return false, ""
}

// Retry if Monitoring operation returns a 409 with a specific message for
// concurrent operations.
func isMonitoringConcurrentEditError(err error) (bool, string) {
Expand Down
11 changes: 11 additions & 0 deletions google/error_retry_predicates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,14 @@ func TestIsCommonRetryableErrorCode_otherError(t *testing.T) {
t.Errorf("Error incorrectly detected as retryable")
}
}

func TestIsOperationReadQuotaError_quotaExceeded(t *testing.T) {
err := googleapi.Error{
Code: 403,
Body: "Quota exceeded for quota group 'OperationReadGroup' and limit 'Operation read requests per 100 seconds' of service 'compute.googleapis.com' for consumer 'project_number:11111111'.",
}
isRetryable, _ := isOperationReadQuotaError(&err)
if !isRetryable {
t.Errorf("Error not detected as retryable")
}
}

0 comments on commit d6e2794

Please sign in to comment.