Ajay Tripathy 4 лет назад
Родитель
Сommit
c169de4553
2 измененных файлов с 10 добавлено и 3 удалено
  1. 4 3
      pkg/costmodel/router.go
  2. 6 0
      pkg/env/costmodelenv.go

+ 4 - 3
pkg/costmodel/router.go

@@ -4,7 +4,6 @@ import (
 	"context"
 	"flag"
 	"fmt"
-	"github.com/kubecost/cost-model/pkg/util/timeutil"
 	"net/http"
 	"reflect"
 	"strconv"
@@ -12,6 +11,8 @@ import (
 	"sync"
 	"time"
 
+	"github.com/kubecost/cost-model/pkg/util/timeutil"
+
 	"k8s.io/klog"
 
 	"github.com/julienschmidt/httprouter"
@@ -401,7 +402,6 @@ func (a *Accesses) ClusterCosts(w http.ResponseWriter, r *http.Request, ps httpr
 		}
 	}
 
-
 	useThanos, _ := strconv.ParseBool(r.URL.Query().Get("multi"))
 
 	if useThanos && !thanos.IsEnabled() {
@@ -896,7 +896,7 @@ func Initialize(additionalConfigWatchers ...ConfigWatchers) *Accesses {
 
 	watchConfigFunc := func(c interface{}) {
 		conf := c.(*v1.ConfigMap)
-		if conf.GetName() == "pricing-configs" {
+		if conf.GetName() == env.GetPricingConfigmapName() {
 			_, err := cloudProvider.UpdateConfigFromConfigMap(conf.Data)
 			if err != nil {
 				klog.Infof("ERROR UPDATING %s CONFIG: %s", "pricing-configs", err.Error())
@@ -926,6 +926,7 @@ func Initialize(additionalConfigWatchers ...ConfigWatchers) *Accesses {
 		if err != nil {
 			klog.Infof("No %s configmap found at installtime, using existing configs: %s", cw.ConfigmapName, err.Error())
 		} else {
+			klog.Infof("Found configmap %s, watching...", configs.Name)
 			watchConfigFunc(configs)
 		}
 	}

+ 6 - 0
pkg/env/costmodelenv.go

@@ -71,8 +71,14 @@ const (
 	LegacyExternalAPIDisabledVar = "LEGACY_EXTERNAL_API_DISABLED"
 
 	PromClusterIDLabelEnvVar = "PROM_CLUSTER_ID_LABEL"
+
+	PricingConfigmapName = "PRICING_CONFIGMAP_NAME"
 )
 
+func GetPricingConfigmapName() string {
+	return Get(PricingConfigmapName, "pricing-configs")
+}
+
 // GetAWSAccessKeyID returns the environment variable value for AWSAccessKeyIDEnvVar which represents
 // the AWS access key for authentication
 func GetAppVersion() string {