Skip to content

Commit

Permalink
fix: add resource quota evaluation timed out to transient (#12536)
Browse files Browse the repository at this point in the history
  • Loading branch information
shuangkun authored and isubasinghe committed May 7, 2024
1 parent 93e981d commit 574fd3a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion util/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func IsTransientErr(err error) bool {
return false
}
err = argoerrs.Cause(err)
isTransient := isExceededQuotaErr(err) || apierr.IsTooManyRequests(err) || isResourceQuotaConflictErr(err) || isTransientNetworkErr(err) || apierr.IsServerTimeout(err) || apierr.IsServiceUnavailable(err) || matchTransientErrPattern(err) ||
isTransient := isExceededQuotaErr(err) || apierr.IsTooManyRequests(err) || isResourceQuotaConflictErr(err) || isResourceQuotaTimeoutErr(err) || isTransientNetworkErr(err) || apierr.IsServerTimeout(err) || apierr.IsServiceUnavailable(err) || matchTransientErrPattern(err) ||
errors.Is(err, NewErrTransient(""))
if isTransient {
log.Infof("Transient error: %v", err)
Expand Down Expand Up @@ -57,6 +57,10 @@ func isResourceQuotaConflictErr(err error) bool {
return apierr.IsConflict(err) && strings.Contains(err.Error(), "Operation cannot be fulfilled on resourcequota")
}

func isResourceQuotaTimeoutErr(err error) bool {
return apierr.IsInternalError(err) && strings.Contains(err.Error(), "resource quota evaluation timed out")
}

func isTransientNetworkErr(err error) bool {
switch err.(type) {
case *net.DNSError, *net.OpError, net.UnknownNetworkError:
Expand Down
4 changes: 4 additions & 0 deletions util/errors/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func TestIsTransientErr(t *testing.T) {
assert.False(t, IsTransientErr(apierr.NewConflict(schema.GroupResource{}, "", nil)))
assert.True(t, IsTransientErr(apierr.NewConflict(schema.GroupResource{Group: "v1", Resource: "resourcequotas"}, "", nil)))
})
t.Run("ResourceQuotaTimeoutErr", func(t *testing.T) {
assert.False(t, IsTransientErr(apierr.NewInternalError(errors.New(""))))
assert.True(t, IsTransientErr(apierr.NewInternalError(errors.New("resource quota evaluation timed out"))))
})
t.Run("ExceededQuotaErr", func(t *testing.T) {
assert.False(t, IsTransientErr(apierr.NewForbidden(schema.GroupResource{}, "", nil)))
assert.True(t, IsTransientErr(apierr.NewForbidden(schema.GroupResource{Group: "v1", Resource: "pods"}, "", errors.New("exceeded quota"))))
Expand Down

0 comments on commit 574fd3a

Please sign in to comment.