Skip to content

Commit 1505143

Browse files
committed
ClusterCacheTracker: fix accessor deletion on health check failure
Signed-off-by: Stefan Büringer [email protected]
1 parent 7399f5f commit 1505143

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

controllers/remote/cluster_cache_tracker.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -647,12 +647,16 @@ func (t *ClusterCacheTracker) healthCheckCluster(ctx context.Context, in *health
647647
}
648648

649649
err := wait.PollUntilContextCancel(ctx, in.interval, true, runHealthCheckWithThreshold)
650-
// An error returned implies the health check has failed a sufficient number of
651-
// times for the cluster to be considered unhealthy
652-
// NB. we are ignoring ErrWaitTimeout because this error happens when the channel is close, that in this case
653-
// happens when the cache is explicitly stopped.
654-
if err != nil && !wait.Interrupted(err) {
650+
// An error returned implies the health check has failed a sufficient number of times for the cluster
651+
// to be considered unhealthy or the cache was stopped and thus the cache context canceled (we pass the
652+
// cache context into wait.PollUntilContextCancel).
653+
// NB. Log all errors that occurred even if this error might just be from a cancel of the cache context
654+
// when the cache is stopped. Logging an error in this case is not a problem and makes debugging easier.
655+
if err != nil {
655656
t.log.Error(err, "Error health checking cluster", "Cluster", klog.KRef(in.cluster.Namespace, in.cluster.Name))
656-
t.deleteAccessor(ctx, in.cluster)
657657
}
658+
// Ensure in any case that the accessor is deleted (even if it is a no-op).
659+
// NB. It is crucial to ensure the accessor was deleted, so it can be later recreated when the
660+
// cluster is reachable again
661+
t.deleteAccessor(ctx, in.cluster)
658662
}

0 commit comments

Comments
 (0)