From eb3425598c387e47478107d725b8555214e4c20f Mon Sep 17 00:00:00 2001 From: alejandroesc Date: Fri, 3 May 2024 10:24:28 -0400 Subject: [PATCH] fixing cache creation, if 0 do not create any, allow flag to create --- src/go/k8s/cmd/main.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/go/k8s/cmd/main.go b/src/go/k8s/cmd/main.go index 45513f9d3..f8eafcfe2 100644 --- a/src/go/k8s/cmd/main.go +++ b/src/go/k8s/cmd/main.go @@ -147,7 +147,7 @@ func main() { additionalControllers []string operatorMode bool enableHelmControllers bool - + helmCacheMaxSize int // allowPVCDeletion controls the PVC deletion feature in the Cluster custom resource. // PVCs will be deleted when its Pod has been deleted and the Node that Pod is assigned to // does not exist, or has the NoExecute taint. This is intended to support the rancher.io/local-path @@ -183,7 +183,8 @@ func main() { flag.StringSliceVar(&additionalControllers, "additional-controllers", []string{""}, fmt.Sprintf("which controllers to run, available: all, %s", strings.Join(availableControllers, ", "))) flag.BoolVar(&operatorMode, "operator-mode", true, "enables to run as an operator, setting this to false will disable cluster (deprecated), redpanda resources reconciliation.") flag.BoolVar(&enableHelmControllers, "enable-helm-controllers", true, "if a namespace is defined and operator mode is true, this enables the use of helm controllers to manage fluxcd helm resources.") - + flag.IntVar(&helmCacheMaxSize, "helm-cache-max-size", 0, + "The maximum size of the cache in number of indexes.") logOptions.BindFlags(flag.CommandLine) clientOptions.BindFlags(flag.CommandLine) kubeConfigOpts.BindFlags(flag.CommandLine) @@ -388,7 +389,12 @@ func main() { cacheRecorder := helmSourceController.MustMakeCacheMetrics() indexTTL := 15 * time.Minute - helmIndexCache := helmSourceController.NewCache(0, indexTTL) + + var helmIndexCache helmSourceController.Cache + if helmCacheMaxSize > 0 { + helmIndexCache = helmSourceController.NewCache(helmCacheMaxSize, 1*time.Minute) + } + chartOpts := helmSourceController.HelmChartReconcilerOptions{ RateLimiter: helper.GetDefaultRateLimiter(), }