Skip to content

Commit b278d73

Browse files
committed
Add check for retry ruota exceeded
1 parent e40bd31 commit b278d73

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

pkg/controllers/nodeclass/validation.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"encoding/json"
2020
"fmt"
2121
"strings"
22+
"time"
2223

2324
"github.com/mitchellh/hashstructure/v2"
2425
"github.com/patrickmn/go-cache"
@@ -130,7 +131,11 @@ func (v *Validation) Reconcile(ctx context.Context, nodeClass *v1.EC2NodeClass)
130131
v.validateRunInstancesAuthorization,
131132
} {
132133
if failureReason, requeue, err := isValid(ctx, nodeClass, nodeClaim, tags); err != nil {
133-
return reconcile.Result{}, err
134+
// if the error is not a retry quota exceeded error then enter exponential backoff
135+
if awserrors.IgnoreRetryQuotaExceededError(err) != nil {
136+
return reconcile.Result{}, err
137+
}
138+
return reconcile.Result{RequeueAfter: time.Minute}, nil
134139
} else if requeue {
135140
return reconcile.Result{Requeue: true}, nil
136141
} else if failureReason != "" {

pkg/errors/errors.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const (
2929
DryRunOperationErrorCode = "DryRunOperation"
3030
UnauthorizedOperationErrorCode = "UnauthorizedOperation"
3131
RateLimitingErrorCode = "RequestLimitExceeded"
32+
RetryQuotaExceededErrorMessage = "retry quota exceeded"
3233
)
3334

3435
var (
@@ -130,6 +131,23 @@ func IgnoreUnauthorizedOperationError(err error) error {
130131
return err
131132
}
132133

134+
func IgnoreRetryQuotaExceededError(err error) error {
135+
if IsRetryQuotaExceededError(err) {
136+
return nil
137+
}
138+
return err
139+
}
140+
141+
func IsRetryQuotaExceededError(err error) bool {
142+
if err == nil {
143+
return false
144+
}
145+
if opErr, ok := lo.ErrorsAs[*smithy.OperationError](err); ok {
146+
return strings.Contains(opErr.Unwrap().Error(), RetryQuotaExceededErrorMessage)
147+
}
148+
return false
149+
}
150+
133151
func IsRateLimitedError(err error) bool {
134152
if err == nil {
135153
return false

0 commit comments

Comments
 (0)