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

add temporary failures as a reason to retry kubernetes failures #2651

Merged
merged 2 commits into from
Sep 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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