Просмотр исходного кода

Merge branch 'develop' into bump-go-toolchain-1.23.5

Cliff Colvin 1 год назад
Родитель
Сommit
804e039bb2
3 измененных файлов с 13 добавлено и 52 удалено
  1. 6 6
      MAINTAINERS.md
  2. 5 18
      pkg/costmodel/allocation_helpers.go
  3. 2 28
      pkg/env/costmodelenv.go

+ 6 - 6
MAINTAINERS.md

@@ -6,13 +6,13 @@ Official list of [OpenCost Maintainers](https://github.com/orgs/opencost/teams/o
 
 | Maintainer | GitHub ID | Affiliation | Email |
 | --------------- | --------- | ----------- | ----------- |
-| Ajay Tripathy | @AjayTripathy | Kubecost | <Ajay@kubecost.com> |
-| Alex Meijer | @ameijer | Kubecost | <ameijer@kubecost.com> |
+| Ajay Tripathy | @AjayTripathy | IBM | <ajay.tripathy@ibm.com> |
+| Alex Meijer | @ameijer | IBM | <alexander.meijer@ibm.com> |
 | Artur Khantimirov | @r2k1 | Microsoft | <akhantimirov@microsoft.com> |
-| Cliff Colvin | @cliffcolvin | Kubecost | <ccolvin@kubecost.com> |
-| Matt Bolt | @​mbolt35 | Kubecost | <matt@kubecost.com> |
-| Niko Kovacevic | @nikovacevic | Kubecost | <niko@kubecost.com> |
-| Sean Holcomb | @Sean-Holcomb | Kubecost | <Sean@kubecost.com> |
+| Cliff Colvin | @cliffcolvin | IBM | <clifford.colvin@ibm.com> |
+| Matt Bolt | @​mbolt35 | IBM | <matthew.bolt@ibm.com> |
+| Niko Kovacevic | @nikovacevic | IBM | <Nicholas.Kovacevic@ibm.com> |
+| Sean Holcomb | @Sean-Holcomb | IBM | <sean.holcomb@ibm.com> |
 
 ## Opencost Emeritus Committers
 We would like to acknowledge previous committers and their huge contributions to our collective success:

+ 5 - 18
pkg/costmodel/allocation_helpers.go

@@ -9,7 +9,6 @@ import (
 
 	"github.com/opencost/opencost/core/pkg/log"
 	"github.com/opencost/opencost/core/pkg/opencost"
-	"github.com/opencost/opencost/core/pkg/util/promutil"
 	"github.com/opencost/opencost/core/pkg/util/timeutil"
 	"github.com/opencost/opencost/pkg/cloud/provider"
 	"github.com/opencost/opencost/pkg/env"
@@ -912,23 +911,11 @@ func resToNodeLabels(resNodeLabels []*prom.QueryResult) map[nodeKey]map[string]s
 			nodeLabels[nodeKey] = map[string]string{}
 		}
 
-		for _, rawK := range env.GetAllocationNodeLabelsIncludeList() {
-			labels := res.GetLabels()
-
-			// Sanitize the given label name to match Prometheus formatting
-			// e.g. topology.kubernetes.io/zone => topology_kubernetes_io_zone
-			k := promutil.SanitizeLabelName(rawK)
-			if v, ok := labels[k]; ok {
-				nodeLabels[nodeKey][k] = v
-				continue
-			}
-
-			// Try with the "label_" prefix, if not found
-			// e.g. topology_kubernetes_io_zone => label_topology_kubernetes_io_zone
-			k = fmt.Sprintf("label_%s", k)
-			if v, ok := labels[k]; ok {
-				nodeLabels[nodeKey][k] = v
-			}
+		labels := res.GetLabels()
+		// labels are retrieved from prometheus here so it will be in prometheus sanitized state
+		// e.g. topology.kubernetes.io/zone => topology_kubernetes_io_zone
+		for labelKey, labelValue := range labels {
+			nodeLabels[nodeKey][labelKey] = labelValue
 		}
 	}
 

+ 2 - 28
pkg/env/costmodelenv.go

@@ -71,7 +71,7 @@ const (
 	MultiClusterBasicAuthPassword = "MC_BASIC_AUTH_PW"
 	MultiClusterBearerToken       = "MC_BEARER_TOKEN"
 
-	InsecureSkipVerify = "INSECURE_SKIP_VERIFY"
+	InsecureSkipVerify   = "INSECURE_SKIP_VERIFY"
 	KubeRbacProxyEnabled = "KUBE_RBAC_PROXY_ENABLED"
 
 	KubeConfigPathEnvVar = "KUBECONFIG_PATH"
@@ -106,8 +106,7 @@ const (
 
 	ETLReadOnlyMode = "ETL_READ_ONLY"
 
-	AllocationNodeLabelsEnabled     = "ALLOCATION_NODE_LABELS_ENABLED"
-	AllocationNodeLabelsIncludeList = "ALLOCATION_NODE_LABELS_INCLUDE_LIST"
+	AllocationNodeLabelsEnabled = "ALLOCATION_NODE_LABELS_ENABLED"
 
 	AssetIncludeLocalDiskCostEnvVar = "ASSET_INCLUDE_LOCAL_DISK_COST"
 
@@ -624,31 +623,6 @@ func GetAllocationNodeLabelsEnabled() bool {
 	return env.GetBool(AllocationNodeLabelsEnabled, true)
 }
 
-var defaultAllocationNodeLabelsIncludeList []string = []string{
-	"cloud.google.com/gke-nodepool",
-	"eks.amazonaws.com/nodegroup",
-	"kubernetes.azure.com/agentpool",
-	"node.kubernetes.io/instance-type",
-	"topology.kubernetes.io/region",
-	"topology.kubernetes.io/zone",
-}
-
-func GetAllocationNodeLabelsIncludeList() []string {
-	// If node labels are not enabled, return an empty list.
-	if !GetAllocationNodeLabelsEnabled() {
-		return []string{}
-	}
-
-	list := env.GetList(AllocationNodeLabelsIncludeList, ",")
-
-	// If node labels are enabled, but the white list is empty, use defaults.
-	if len(list) == 0 {
-		return defaultAllocationNodeLabelsIncludeList
-	}
-
-	return list
-}
-
 func GetAssetIncludeLocalDiskCost() bool {
 	return env.GetBool(AssetIncludeLocalDiskCostEnvVar, true)
 }