Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Commit

Permalink
add temporary failures as a reason to retry kubernetes failures (#2651)…
Browse files Browse the repository at this point in the history
… (#2656)

(cherry picked from commit 03d0169)
  • Loading branch information
Kevin Nisbet authored Sep 28, 2021
1 parent f111aeb commit 06bb056
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/kubernetes/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,26 @@ package kubernetes

import (
"github.com/cenkalti/backoff"
"github.com/gravitational/gravity/lib/utils"
"github.com/gravitational/rigging"
"github.com/gravitational/trace"
"k8s.io/apimachinery/pkg/api/errors"
)

// RetryOnUpdateConflict retries on update conflict errors
// RetryOnUpdateConflict retries on update conflict errors (and temporary failures).
func RetryOnUpdateConflict(err error) error {
if err == nil {
return nil
}
origErr := trace.Unwrap(err)
switch {
case errors.IsConflict(origErr):
case errors.IsConflict(origErr),
errors.IsServiceUnavailable(origErr),
errors.IsServerTimeout(origErr),
errors.IsTimeout(origErr),
errors.IsInternalError(origErr),
errors.IsTooManyRequests(origErr),
utils.IsTransientClusterError(origErr):
return rigging.ConvertError(origErr)
default:
return &backoff.PermanentError{Err: err}
Expand Down

0 comments on commit 06bb056

Please sign in to comment.