Skip to content

Commit e8e5e42

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

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 (
@@ -123,6 +124,23 @@ func IsUnauthorizedOperationError(err error) bool {
123124
return false
124125
}
125126

127+
func IgnoreRetryQuotaExceededError(err error) error {
128+
if IsRetryQuotaExceededError(err) {
129+
return nil
130+
}
131+
return err
132+
}
133+
134+
func IsRetryQuotaExceededError(err error) bool {
135+
if err == nil {
136+
return false
137+
}
138+
if opErr, ok := lo.ErrorsAs[*smithy.OperationError](err); ok {
139+
return strings.Contains(opErr.Unwrap().Error(), RetryQuotaExceededErrorMessage)
140+
}
141+
return false
142+
}
143+
126144
func IgnoreUnauthorizedOperationError(err error) error {
127145
if IsUnauthorizedOperationError(err) {
128146
return nil

0 commit comments

Comments
 (0)