From 9a03edb8e71e5addf5b14e2c9520d23351ee0594 Mon Sep 17 00:00:00 2001 From: Jesse Suen Date: Thu, 12 Oct 2023 09:58:44 -0700 Subject: [PATCH] fix: remove lock acquisition in ClusterCache.GetAPIResources() (#543) Signed-off-by: Jesse Suen --- pkg/cache/cluster.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/cache/cluster.go b/pkg/cache/cluster.go index 52be5b7da..02ca18911 100644 --- a/pkg/cache/cluster.go +++ b/pkg/cache/cluster.go @@ -300,10 +300,11 @@ func (c *clusterCache) GetServerVersion() string { } // GetAPIResources returns information about observed API resources +// This method is called frequently during reconciliation to pass API resource info to `helm template` +// NOTE: we do not provide any consistency guarantees about the returned list. The list might be +// updated in place (anytime new CRDs are introduced or removed). If necessary, a separate method +// would need to be introduced to return a copy of the list so it can be iterated consistently. func (c *clusterCache) GetAPIResources() []kube.APIResourceInfo { - c.lock.RLock() - defer c.lock.RUnlock() - return c.apiResources }