Ver Fonte

make cache selection configurable

Signed-off-by: r2k1 <yokree@gmail.com>
r2k1 há 1 ano atrás
pai
commit
fee580c7c9
2 ficheiros alterados com 11 adições e 0 exclusões
  1. 3 0
      pkg/clustercache/clustercache.go
  2. 8 0
      pkg/env/costmodelenv.go

+ 3 - 0
pkg/clustercache/clustercache.go

@@ -443,6 +443,9 @@ func initializeCache(wc WatchController, wg *sync.WaitGroup, cancel chan struct{
 }
 
 func NewKubernetesClusterCache(client kubernetes.Interface) ClusterCache {
+	if env.GetUseCacheV1() {
+		return NewKubernetesClusterCacheV1(client)
+	}
 	return NewKubernetesClusterCacheV2(client)
 }
 

+ 8 - 0
pkg/env/costmodelenv.go

@@ -140,6 +140,8 @@ const (
 	OCIPricingURL = "OCI_PRICING_URL"
 
 	CarbonEstimatesEnabledEnvVar = "CARBON_ESTIMATES_ENABLED"
+
+	UseCacheV1 = "USE_CACHE_V1"
 )
 
 const DefaultConfigMountPath = "/var/configs"
@@ -728,3 +730,9 @@ func GetCustomCostRefreshRateHours() string {
 func IsCarbonEstimatesEnabled() bool {
 	return env.GetBool(CarbonEstimatesEnabledEnvVar, false)
 }
+
+// GetUseCacheV1 is a temporary flag to allow users to opt-in to using the old cache
+// Mainly for comparison purposes
+func GetUseCacheV1() bool {
+	return env.GetBool(UseCacheV1, false)
+}