Skip to content

Commit f953079

Browse files
Add operation retry for exceeded quota group OperationReadGroup (#4599) (#3077)
Signed-off-by: Modular Magician <[email protected]>
1 parent a01916a commit f953079

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

.changelog/4599.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
compute: fixed an issue where exceeding the operation rate limit would fail without retrying
3+
```

google-beta/common_operation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func CommonRefreshFunc(w Waiter) resource.StateRefreshFunc {
111111
op, err := w.QueryOp()
112112
if err != nil {
113113
// Retry 404 when getting operation (not resource state)
114-
if isRetryableError(err, isNotFoundRetryableError("GET operation")) {
114+
if isRetryableError(err, isNotFoundRetryableError("GET operation"), isOperationReadQuotaError) {
115115
log.Printf("[DEBUG] Dismissed retryable error on GET operation %q: %s", w.OpName(), err)
116116
return nil, "done: false", nil
117117
}

google-beta/error_retry_predicates.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,17 @@ func isBigqueryIAMQuotaError(err error) (bool, string) {
216216
return false, ""
217217
}
218218

219+
// Retry if operation returns a 403 with the message for
220+
// exceeding the quota limit for 'OperationReadGroup'
221+
func isOperationReadQuotaError(err error) (bool, string) {
222+
if gerr, ok := err.(*googleapi.Error); ok {
223+
if gerr.Code == 403 && strings.Contains(gerr.Body, "Quota exceeded for quota group 'OperationReadGroup'") {
224+
return true, "Waiting for quota to refresh"
225+
}
226+
}
227+
return false, ""
228+
}
229+
219230
// Retry if Monitoring operation returns a 409 with a specific message for
220231
// concurrent operations.
221232
func isMonitoringConcurrentEditError(err error) (bool, string) {

google-beta/error_retry_predicates_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,14 @@ func TestIsCommonRetryableErrorCode_otherError(t *testing.T) {
7878
t.Errorf("Error incorrectly detected as retryable")
7979
}
8080
}
81+
82+
func TestIsOperationReadQuotaError_quotaExceeded(t *testing.T) {
83+
err := googleapi.Error{
84+
Code: 403,
85+
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'.",
86+
}
87+
isRetryable, _ := isOperationReadQuotaError(&err)
88+
if !isRetryable {
89+
t.Errorf("Error not detected as retryable")
90+
}
91+
}

0 commit comments

Comments
 (0)