Skip to content

Commit 83227c1

Browse files
bugfix: wait for each cluster's cache to be ready before adding to clusters list
1 parent 7754afd commit 83227c1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

providers/kubeconfig/provider.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ func (p *Provider) handleSecret(ctx context.Context, secret *corev1.Secret, mgr
237237
}
238238
}()
239239

240+
// Wait for cache to be ready
241+
log.Info("Waiting for cluster cache to be ready")
242+
if !cl.GetCache().WaitForCacheSync(clusterCtx) {
243+
cancel() // Cancel context before returning error
244+
return fmt.Errorf("failed to wait for cache sync")
245+
}
246+
log.Info("Cluster cache is ready")
247+
240248
// Store the cluster
241249
p.lock.Lock()
242250
p.clusters[clusterName] = cl

0 commit comments

Comments
 (0)