diff --git a/internal/corrosion/subscribe.go b/internal/corrosion/subscribe.go index c29f6876..7c76b9b9 100644 --- a/internal/corrosion/subscribe.go +++ b/internal/corrosion/subscribe.go @@ -290,6 +290,7 @@ func (c *APIClient) resubscribeWithBackoffFn(id string) func(context.Context, ui return nil } return func(ctx context.Context, fromChange uint64) (*Subscription, error) { + boff := backoff.WithContext(c.newResubBackoff(), ctx) return backoff.RetryWithData(func() (*Subscription, error) { sub, err := c.ResubscribeContext(ctx, id, fromChange) if err != nil { @@ -300,11 +301,14 @@ func (c *APIClient) resubscribeWithBackoffFn(id string) func(context.Context, ui "id", id, "from_change", fromChange) return nil, backoff.Permanent(fmt.Errorf("resubscribe to %s: %w", id, err)) } - slog.Debug("Failed to resubscribe to Corrosion query. Retrying with backoff.", - "id", id, "from_change", fromChange, "err", err) + // Don't log retries triggered by context cancellation, the backoff will stop immediately. + if ctx.Err() == nil { + slog.Debug("Failed to resubscribe to Corrosion query. Retrying with backoff.", + "id", id, "from_change", fromChange, "err", err) + } } return sub, err - }, c.newResubBackoff()) + }, boff) } } diff --git a/internal/machine/cluster.go b/internal/machine/cluster.go index 710127ad..d46610a5 100644 --- a/internal/machine/cluster.go +++ b/internal/machine/cluster.go @@ -620,7 +620,7 @@ func (cc *clusterController) syncDockerContainers(ctx context.Context) error { return nil } if err := backoff.Retry(watchAndSync, boff); err != nil { - if errors.Is(err, context.Canceled) { + if ctx.Err() != nil { return nil } return fmt.Errorf("watch and sync containers to cluster store: %w", err) diff --git a/internal/machine/docker/controller.go b/internal/machine/docker/controller.go index a82ae79b..96f4bc2b 100644 --- a/internal/machine/docker/controller.go +++ b/internal/machine/docker/controller.go @@ -139,7 +139,7 @@ func (c *Controller) WatchAndSyncContainers(ctx context.Context) error { return fmt.Errorf("sync containers to cluster store: %w", err) } case err := <-errCh: - if errors.Is(err, context.Canceled) { + if ctx.Err() != nil { return nil } return fmt.Errorf("receive Docker event: %w", err)