Bladeren bron

Merge pull request #289 from kubecost/AjayTripathy-update-fixes

Ajay tripathy update fixes
Ajay Tripathy 6 jaren geleden
bovenliggende
commit
be492b8164
4 gewijzigde bestanden met toevoegingen van 8 en 11 verwijderingen
  1. 1 1
      cloud/gcpprovider.go
  2. 1 0
      cloud/provider.go
  3. 1 1
      costmodel/costmodel.go
  4. 5 9
      costmodel/router.go

+ 1 - 1
cloud/gcpprovider.go

@@ -279,7 +279,7 @@ func (gcp *GCP) ClusterInfo() (map[string]string, error) {
 
 	attribute, err := metadataClient.InstanceAttributeValue("cluster-name")
 	if err != nil {
-		return nil, err
+		klog.Infof("Error loading metadata cluster-name: %s", err.Error())
 	}
 
 	c, err := gcp.GetConfig()

+ 1 - 0
cloud/provider.go

@@ -154,6 +154,7 @@ type CustomPricing struct {
 	SharedCosts           map[string]string `json:"sharedCost"`
 	ClusterName           string            `json:"clusterName"`
 	SharedNamespaces      string            `json:"sharedNamespaces"`
+	ReadOnly              string            `json:"readOnly"`
 }
 
 // Provider represents a k8s provider.

+ 1 - 1
costmodel/costmodel.go

@@ -902,7 +902,7 @@ func findDeletedNodeInfo(cli prometheusClient.Client, missingNodes map[string]*c
 		}
 
 		if len(cpuCosts) == 0 {
-			klog.V(1).Infof("Historical data for node prices not available. Ingest this server's /metrics endpoint to get that data.")
+			klog.V(1).Infof("Kubecost prometheus metrics not currently available. Ingest this server's /metrics endpoint to get that data.")
 		}
 
 		for node, costv := range cpuCosts {

+ 5 - 9
costmodel/router.go

@@ -643,7 +643,7 @@ func (a *Accesses) recordPrices() {
 				cpuCost, _ := strconv.ParseFloat(node.VCPUCost, 64)
 				if math.IsNaN(cpuCost) || math.IsInf(cpuCost, 0) {
 					cpuCost, _ = strconv.ParseFloat(cfg.CPU, 64)
-					if  math.IsNaN(cpuCost) || math.IsInf(cpuCost, 0) {
+					if math.IsNaN(cpuCost) || math.IsInf(cpuCost, 0) {
 						cpuCost = 0
 					}
 				}
@@ -654,7 +654,7 @@ func (a *Accesses) recordPrices() {
 				ramCost, _ := strconv.ParseFloat(node.RAMCost, 64)
 				if math.IsNaN(ramCost) || math.IsInf(ramCost, 0) {
 					ramCost, _ = strconv.ParseFloat(cfg.RAM, 64)
-					if  math.IsNaN(ramCost) || math.IsInf(ramCost, 0) {
+					if math.IsNaN(ramCost) || math.IsInf(ramCost, 0) {
 						ramCost = 0
 					}
 				}
@@ -669,7 +669,7 @@ func (a *Accesses) recordPrices() {
 				gpuCost, _ := strconv.ParseFloat(node.GPUCost, 64)
 				if math.IsNaN(gpuCost) || math.IsInf(gpuCost, 0) {
 					gpuCost, _ = strconv.ParseFloat(cfg.GPU, 64)
-					if  math.IsNaN(gpuCost) || math.IsInf(gpuCost, 0) {
+					if math.IsNaN(gpuCost) || math.IsInf(gpuCost, 0) {
 						gpuCost = 0
 					}
 				}
@@ -868,8 +868,9 @@ func Initialize() {
 	configs, err := kubeClientset.CoreV1().ConfigMaps(kubecostNamespace).Get("pricing-configs", metav1.GetOptions{})
 	if err != nil {
 		klog.Infof("ERROR FETCHING configmap: %s", err.Error())
+	} else {
+		watchConfigFunc(configs)
 	}
-	watchConfigFunc(configs)
 
 	k8sCache.SetConfigMapUpdateFunc(watchConfigFunc)
 
@@ -1039,12 +1040,7 @@ func Initialize() {
 	Router.GET("/costDataModelRangeLarge", A.CostDataModelRangeLarge)
 	Router.GET("/outOfClusterCosts", A.OutOfClusterCostsWithCache)
 	Router.GET("/allNodePricing", A.GetAllNodePricing)
-	Router.GET("/getConfigs", A.GetConfigs)
 	Router.POST("/refreshPricing", A.RefreshPricingData)
-	Router.POST("/updateSpotInfoConfigs", A.UpdateSpotInfoConfigs)
-	Router.POST("/updateAthenaInfoConfigs", A.UpdateAthenaInfoConfigs)
-	Router.POST("/updateBigQueryInfoConfigs", A.UpdateBigQueryInfoConfigs)
-	Router.POST("/updateConfigByKey", A.UpdateConfigByKey)
 	Router.GET("/clusterCostsOverTime", A.ClusterCostsOverTime)
 	Router.GET("/clusterCosts", A.ClusterCosts)
 	Router.GET("/validatePrometheus", A.GetPrometheusMetadata)