Skip to content

Commit

Permalink
fix: make etcd errors transient (#12567)
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Clucas <alan@clucas.org>
Signed-off-by: Isitha Subasinghe <isubasinghe@student.unimelb.edu.au>
  • Loading branch information
Joibel authored and isubasinghe committed Feb 28, 2024
1 parent 02a3e2e commit a5bf996
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion util/errors/errors.go
Expand Up @@ -28,7 +28,15 @@ func IsTransientErr(err error) bool {
return false
}
err = argoerrs.Cause(err)
isTransient := isExceededQuotaErr(err) || apierr.IsTooManyRequests(err) || isResourceQuotaConflictErr(err) || isResourceQuotaTimeoutErr(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) ||
isTransientEtcdErr(err) ||
matchTransientErrPattern(err) ||
errors.Is(err, NewErrTransient(""))
if isTransient {
log.Infof("Transient error: %v", err)
Expand Down Expand Up @@ -61,6 +69,16 @@ func isResourceQuotaTimeoutErr(err error) bool {
return apierr.IsInternalError(err) && strings.Contains(err.Error(), "resource quota evaluation timed out")
}

func isTransientEtcdErr(err error) bool {
// Some clusters expose these (transient) etcd errors to the caller
if strings.Contains(err.Error(), "etcdserver: leader changed") {
return true
} else if strings.Contains(err.Error(), "etcdserver: request timed out") {
return true
}
return false
}

func isTransientNetworkErr(err error) bool {
switch err.(type) {
case *net.DNSError, *net.OpError, net.UnknownNetworkError:
Expand Down

0 comments on commit a5bf996

Please sign in to comment.