Skip to content

Commit

Permalink
Fix error handling in EtcdMemberReconciler
Browse files Browse the repository at this point in the history
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="<nil>"
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="<nil>"
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="<nil>"
...
```

It actually hides the transient errors encountered.

Signed-off-by: Jussi Nummelin <[email protected]>
  • Loading branch information
jnummelin committed May 16, 2024
1 parent 4141997 commit 64ea576
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/component/controller/etcd_member_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...",
Expand All @@ -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 ...",
Expand Down

0 comments on commit 64ea576

Please sign in to comment.