From e419668f8bf5a49bb78fcce54e5f8b08bdf958e9 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Fri, 30 Aug 2019 17:53:54 -0600 Subject: [PATCH] fix: clear the discovery cache after CRDs are installed This fixes an issue in which a chart could not contain both a CRD and an instance of that CRD. It works around a stale cache by force cache invalidation whenever a CRD is added. Closes #6316 Signed-off-by: Matt Butcher --- pkg/action/install.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/action/install.go b/pkg/action/install.go index 2516ae62d..6efcdf22e 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -169,6 +169,15 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release. } return i.failRelease(rel, err) } + + // Invalidate the local cache. + if discoveryClient, err := i.cfg.RESTClientGetter.ToDiscoveryClient(); err != nil { + // On error, we don't want to bail out, since this is unlikely + // to impact the majority of charts. + i.cfg.Log("Could not clear the discovery cache: %s", err) + } else { + discoveryClient.Invalidate() + } } }