From 76fc65fda5ea49e1fac1919148e4c28004298eff Mon Sep 17 00:00:00 2001 From: Aljoscha Poertner Date: Thu, 16 Feb 2023 11:22:13 +0100 Subject: [PATCH] fix(remote): requeue health check during cluster accessor creation Signed-off-by: Aljoscha Poertner --- controllers/remote/cluster_cache_tracker.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/controllers/remote/cluster_cache_tracker.go b/controllers/remote/cluster_cache_tracker.go index 1670341081e0..fcdbcc7b46f3 100644 --- a/controllers/remote/cluster_cache_tracker.go +++ b/controllers/remote/cluster_cache_tracker.go @@ -527,6 +527,13 @@ func (t *ClusterCacheTracker) healthCheckCluster(ctx context.Context, in *health } if _, ok := t.loadAccessor(in.cluster); !ok { + // If there is no accessor but the cluster is locked, we're probably in the middle of the cluster accessor + // creation and we should requeue the health check until it's done. + if ok := t.clusterLock.TryLock(in.cluster); !ok { + t.log.V(4).Info("Waiting for cluster to be unlocked. Requeuing health check") + return false, nil + } + t.clusterLock.Unlock(in.cluster) // Cache for this cluster has already been cleaned up. // Nothing to do, so return true. return true, nil