Переглянути джерело

Revert "Revert clusterID from cluster name back to environment clusterID; append new clusterName value to CostData struct."

This reverts commit 051bab6bd548359a439eeb4a7673f917792f30ed.
Matt Bolt 6 роки тому
батько
коміт
56cc162a1d
1 змінених файлів з 3 додано та 9 видалено
  1. 3 9
      costmodel/costmodel.go

+ 3 - 9
costmodel/costmodel.go

@@ -6,7 +6,6 @@ import (
 	"fmt"
 	"fmt"
 	"math"
 	"math"
 	"net/http"
 	"net/http"
-	"os"
 	"sort"
 	"sort"
 	"strconv"
 	"strconv"
 	"strings"
 	"strings"
@@ -85,7 +84,6 @@ type CostData struct {
 	Labels          map[string]string            `json:"labels,omitempty"`
 	Labels          map[string]string            `json:"labels,omitempty"`
 	NamespaceLabels map[string]string            `json:"namespaceLabels,omitempty"`
 	NamespaceLabels map[string]string            `json:"namespaceLabels,omitempty"`
 	ClusterID       string                       `json:"clusterId"`
 	ClusterID       string                       `json:"clusterId"`
-	ClusterName     string                       `json:"clusterName"`
 }
 }
 
 
 type Vector struct {
 type Vector struct {
@@ -269,9 +267,7 @@ func (cm *CostModel) ComputeCostData(cli prometheusClient.Client, clientset kube
 	queryNetInternetRequests := fmt.Sprintf(queryInternetNetworkUsage, window, "")
 	queryNetInternetRequests := fmt.Sprintf(queryInternetNetworkUsage, window, "")
 	normalization := fmt.Sprintf(normalizationStr, window, offset)
 	normalization := fmt.Sprintf(normalizationStr, window, offset)
 
 
-	// Retrieve cluster ID environment
-	clusterID := os.Getenv(clusterIDKey)
-	// Retrieve cluster name from provider
+	// Retrieve cluster ID from cloud provider's cluster info
 	clusterName := cloud.ClusterName(cp)
 	clusterName := cloud.ClusterName(cp)
 
 
 	var wg sync.WaitGroup
 	var wg sync.WaitGroup
@@ -566,8 +562,7 @@ func (cm *CostModel) ComputeCostData(cli prometheusClient.Client, clientset kube
 					NetworkData:     netReq,
 					NetworkData:     netReq,
 					Labels:          podLabels,
 					Labels:          podLabels,
 					NamespaceLabels: nsLabels,
 					NamespaceLabels: nsLabels,
-					ClusterID:       clusterID,
-					ClusterName:     clusterName,
+					ClusterID:       clusterName,
 				}
 				}
 				costs.CPUAllocation = getContainerAllocation(costs.CPUReq, costs.CPUUsed)
 				costs.CPUAllocation = getContainerAllocation(costs.CPUReq, costs.CPUUsed)
 				costs.RAMAllocation = getContainerAllocation(costs.RAMReq, costs.RAMUsed)
 				costs.RAMAllocation = getContainerAllocation(costs.RAMReq, costs.RAMUsed)
@@ -636,8 +631,7 @@ func (cm *CostModel) ComputeCostData(cli prometheusClient.Client, clientset kube
 				CPUUsed:         CPUUsedV,
 				CPUUsed:         CPUUsedV,
 				GPUReq:          GPUReqV,
 				GPUReq:          GPUReqV,
 				NamespaceLabels: namespacelabels,
 				NamespaceLabels: namespacelabels,
-				ClusterID:       clusterID,
-				ClusterName:     clusterName,
+				ClusterID:       clusterName,
 			}
 			}
 			costs.CPUAllocation = getContainerAllocation(costs.CPUReq, costs.CPUUsed)
 			costs.CPUAllocation = getContainerAllocation(costs.CPUReq, costs.CPUUsed)
 			costs.RAMAllocation = getContainerAllocation(costs.RAMReq, costs.RAMUsed)
 			costs.RAMAllocation = getContainerAllocation(costs.RAMReq, costs.RAMUsed)