From 64ea5765398b86b4dd578b3dc0c52eade6c33f46 Mon Sep 17 00:00:00 2001 From: Jussi Nummelin Date: Thu, 16 May 2024 15:18:04 +0200 Subject: [PATCH] Fix error handling in EtcdMemberReconciler The watch for CRD getting ready used wrong error when checking if it is retriable. This results in bogus logging and a "busyloop": ``` time="2024-05-16 10:05:45" level=info msg="Transient error while watching etcdmember CRD, last observed version is \"\", starting over after 0s ..." component=etcdMemberReconciler error="" time="2024-05-16 10:05:45" level=info msg="Transient error while watching etcdmember CRD, last observed version is \"\", starting over after 0s ..." component=etcdMemberReconciler error="" time="2024-05-16 10:05:45" level=info msg="Transient error while watching etcdmember CRD, last observed version is \"\", starting over after 0s ..." component=etcdMemberReconciler error="" ... ``` It actually hides the transient errors encountered. Signed-off-by: Jussi Nummelin --- pkg/component/controller/etcd_member_reconciler.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/component/controller/etcd_member_reconciler.go b/pkg/component/controller/etcd_member_reconciler.go index 0b056dda6e4d..71421eb9b75a 100644 --- a/pkg/component/controller/etcd_member_reconciler.go +++ b/pkg/component/controller/etcd_member_reconciler.go @@ -142,9 +142,10 @@ func (e *EtcdMemberReconciler) waitForCRD(ctx context.Context) error { log.Info("waiting to see EtcdMember CRD ready") return watch.FromClient[*crdList, crd](ec.CustomResourceDefinitions()). WithObjectName(fmt.Sprintf("%s.%s", "etcdmembers", "etcd.k0sproject.io")). - WithErrorCallback(func(cbErr error) (retryDelay time.Duration, err error) { - if retryAfter, e := watch.IsRetryable(err); e == nil { - log.WithError(err).Infof( + WithErrorCallback(func(cbErr error) (time.Duration, error) { + retryAfter, e := watch.IsRetryable(cbErr) + if e == nil { + log.WithError(cbErr).Infof( "Transient error while watching etcdmember CRD"+ ", last observed version is %q"+ ", starting over after %s ...", @@ -153,8 +154,8 @@ func (e *EtcdMemberReconciler) waitForCRD(ctx context.Context) error { return retryAfter, nil } - retryAfter := 10 * time.Second - log.WithError(err).Errorf( + retryAfter = 10 * time.Second + log.WithError(e).Errorf( "Failed to watch for etcdmember CRD"+ ", last observed version is %q"+ ", starting over after %s ...",