From 2a00d82f9fa750357e6120ad148661307a44277a Mon Sep 17 00:00:00 2001 From: jswxstw Date: Thu, 29 Aug 2024 17:05:14 +0800 Subject: [PATCH] fix: remove non-transient logs on missing artifact-repo configmaps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #9085 by eliminating log-messages for override ConfigMaps which do not have to exist. Signed-off-by: Thor K. Høgås --- util/errors/errors.go | 27 ++++++++++++++----- .../artifactrepositories.go | 2 +- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/util/errors/errors.go b/util/errors/errors.go index 2982be216fd7..fe12165526ce 100644 --- a/util/errors/errors.go +++ b/util/errors/errors.go @@ -23,12 +23,31 @@ func IgnoreContainerNotFoundErr(err error) error { return err } +// IsTransientErr reports whether the error is transient and logs it. func IsTransientErr(err error) bool { + isTransient := IsTransientErrQuiet(err) + if !isTransient { + log.Warnf("Non-transient error: %v", err) + } + return isTransient +} + +// IsTransientErrQuiet reports whether the error is transient and logs only if it is. +func IsTransientErrQuiet(err error) bool { + isTransient := isTransientErr(err) + if isTransient { + log.Infof("Transient error: %v", err) + } + return isTransient +} + +// isTransientErr reports whether the error is transient. +func isTransientErr(err error) bool { if err == nil { return false } err = argoerrs.Cause(err) - isTransient := isExceededQuotaErr(err) || + return isExceededQuotaErr(err) || apierr.IsTooManyRequests(err) || isResourceQuotaConflictErr(err) || isResourceQuotaTimeoutErr(err) || @@ -39,12 +58,6 @@ func IsTransientErr(err error) bool { matchTransientErrPattern(err) || errors.Is(err, NewErrTransient("")) || isTransientSqbErr(err) - if isTransient { - log.Infof("Transient error: %v", err) - } else { - log.Warnf("Non-transient error: %v", err) - } - return isTransient } func matchTransientErrPattern(err error) bool { diff --git a/workflow/artifactrepositories/artifactrepositories.go b/workflow/artifactrepositories/artifactrepositories.go index 4829cb4d6112..3bc79a36394d 100644 --- a/workflow/artifactrepositories/artifactrepositories.go +++ b/workflow/artifactrepositories/artifactrepositories.go @@ -90,7 +90,7 @@ func (s *artifactRepositories) get(ctx context.Context, ref *wfv1.ArtifactReposi err := waitutil.Backoff(retry.DefaultRetry, func() (bool, error) { var err error cm, err = s.kubernetesInterface.CoreV1().ConfigMaps(namespace).Get(ctx, configMap, metav1.GetOptions{}) - return !errorsutil.IsTransientErr(err), err + return !errorsutil.IsTransientErrQuiet(err), err }) if err != nil { return nil, err