From bf05b5a4ca035068f60740c4d7a7fd193dce10c9 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 776448439272..4add86f6f9f5 100644 --- a/controllers/remote/cluster_cache_tracker.go +++ b/controllers/remote/cluster_cache_tracker.go @@ -528,6 +528,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