Преглед изворни кода

use reduced node struct

Signed-off-by: r2k1 <yokree@gmail.com>
r2k1 пре 2 година
родитељ
комит
d95ccf9c64

+ 3 - 3
pkg/cloud/alibaba/provider.go

@@ -854,7 +854,7 @@ func (alibabaNodeKey *AlibabaNodeKey) GPUCount() int {
 }
 
 // Get's the key for the k8s node input
-func (alibaba *Alibaba) GetKey(mapValue map[string]string, node *v1.Node) models.Key {
+func (alibaba *Alibaba) GetKey(mapValue map[string]string, node *clustercache.Node) models.Key {
 	slimK8sNode := generateSlimK8sNodeFromV1Node(node)
 
 	var aak *credentials.AccessKeyCredential
@@ -1244,7 +1244,7 @@ func getSystemDiskInfoOfANode(instanceID, regionID string, client *sdk.Client, s
 }
 
 // generateSlimK8sNodeFromV1Node generates SlimK8sNode struct from v1.Node to fetch pricing information and call alibaba API.
-func generateSlimK8sNodeFromV1Node(node *v1.Node) *SlimK8sNode {
+func generateSlimK8sNodeFromV1Node(node *clustercache.Node) *SlimK8sNode {
 	var regionID, osType, instanceType, providerID, priceUnit, instanceFamily string
 	var memorySizeInKiB string // TO-DO: try to convert it into float
 	var ok, IsIoOptimized bool
@@ -1263,7 +1263,7 @@ func generateSlimK8sNodeFromV1Node(node *v1.Node) *SlimK8sNode {
 
 	instanceFamily = getInstanceFamilyFromType(instanceType)
 	memorySizeInKiB = fmt.Sprintf("%s", node.Status.Capacity.Memory())
-	providerID = node.Spec.ProviderID // Alibaba Cloud provider doesnt follow convention of prefix with cloud provider name
+	providerID = node.SpecProviderID // Alibaba Cloud provider doesnt follow convention of prefix with cloud provider name
 
 	// Looking at current Instance offering , all of the Instances seem to be I/O optimized - https://www.alibabacloud.com/help/en/elastic-compute-service/latest/instance-family
 	// Basic price Json has it as part of the key so defaulting to true.

+ 3 - 2
pkg/cloud/alibaba/provider_test.go

@@ -8,6 +8,7 @@ import (
 	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
 	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/signers"
 	"github.com/opencost/opencost/pkg/cloud/models"
+	"github.com/opencost/opencost/pkg/clustercache"
 	v1 "k8s.io/api/core/v1"
 	"k8s.io/apimachinery/pkg/api/resource"
 )
@@ -604,7 +605,7 @@ func TestDetermineKeyForPricing(t *testing.T) {
 }
 
 func TestGenerateSlimK8sNodeFromV1Node(t *testing.T) {
-	testv1Node := &v1.Node{}
+	testv1Node := &clustercache.Node{}
 	testv1Node.Labels = make(map[string]string)
 	testv1Node.Labels["topology.kubernetes.io/region"] = "us-east-1"
 	testv1Node.Labels["beta.kubernetes.io/os"] = "linux"
@@ -614,7 +615,7 @@ func TestGenerateSlimK8sNodeFromV1Node(t *testing.T) {
 	}
 	cases := []struct {
 		name             string
-		testNode         *v1.Node
+		testNode         *clustercache.Node
 		expectedSlimNode *SlimK8sNode
 	}{
 		{

+ 4 - 4
pkg/cloud/aws/provider.go

@@ -771,7 +771,7 @@ func getStorageClassTypeFrom(provisioner string) string {
 }
 
 // GetKey maps node labels to information needed to retrieve pricing data
-func (aws *AWS) GetKey(labels map[string]string, n *v1.Node) models.Key {
+func (aws *AWS) GetKey(labels map[string]string, n *clustercache.Node) models.Key {
 	return &awsKey{
 		SpotLabelName:  aws.SpotLabelName,
 		SpotLabelValue: aws.SpotLabelValue,
@@ -793,13 +793,13 @@ func (aws *AWS) ClusterManagementPricing() (string, float64, error) {
 }
 
 // Use the pricing data from the current region. Fall back to using all region data if needed.
-func (aws *AWS) getRegionPricing(nodeList []*v1.Node) (*http.Response, string, error) {
+func (aws *AWS) getRegionPricing(nodeList []*clustercache.Node) (*http.Response, string, error) {
 
 	pricingURL := "https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/"
 	region := ""
 	multiregion := false
 	for _, n := range nodeList {
-		labels := n.GetLabels()
+		labels := n.Labels
 		currentNodeRegion := ""
 		if r, ok := util.GetRegion(labels); ok {
 			currentNodeRegion = r
@@ -883,7 +883,7 @@ func (aws *AWS) DownloadPricingData() error {
 			aws.clusterProvisioner = "KOPS"
 		}
 
-		labels := n.GetObjectMeta().GetLabels()
+		labels := n.Labels
 		key := aws.GetKey(labels, n)
 		inputkeys[key.Features()] = true
 	}

+ 2 - 2
pkg/cloud/azure/provider.go

@@ -675,7 +675,7 @@ func (az *Azure) loadAzureStorageConfig(force bool) (*AzureStorageConfig, error)
 	return &asc, nil
 }
 
-func (az *Azure) GetKey(labels map[string]string, n *v1.Node) models.Key {
+func (az *Azure) GetKey(labels map[string]string, n *clustercache.Node) models.Key {
 	cfg, err := az.GetConfig()
 	if err != nil {
 		log.Infof("Error loading azure custom pricing information")
@@ -772,7 +772,7 @@ func (az *Azure) GetManagementPlatform() (string, error) {
 
 	if len(nodes) > 0 {
 		n := nodes[0]
-		providerID := n.Spec.ProviderID
+		providerID := n.SpecProviderID
 		if strings.Contains(providerID, "aks") {
 			return "aks", nil
 		}

+ 4 - 4
pkg/cloud/gcp/provider.go

@@ -1078,7 +1078,7 @@ func (gcp *GCP) DownloadPricingData() error {
 
 	defaultRegion := "" // Sometimes, PVs may be missing the region label. In that case assume that they are in the same region as the nodes
 	for _, n := range nodeList {
-		labels := n.GetObjectMeta().GetLabels()
+		labels := n.Labels
 		if _, ok := labels["cloud.google.com/gke-nodepool"]; ok { // The node is part of a GKE nodepool, so you're paying a cluster management cost
 			gcp.clusterManagementPrice = 0.10
 			gcp.clusterProvisioner = "GKE"
@@ -1275,12 +1275,12 @@ func (gcp *GCP) ApplyReservedInstancePricing(nodes map[string]*models.Node) {
 		}
 	}
 
-	gcpNodes := make(map[string]*v1.Node)
+	gcpNodes := make(map[string]*clustercache.Node)
 	currentNodes := gcp.Clientset.GetAllNodes()
 
 	// Create a node name -> node map
 	for _, gcpNode := range currentNodes {
-		gcpNodes[gcpNode.GetName()] = gcpNode
+		gcpNodes[gcpNode.Name] = gcpNode
 	}
 
 	// go through all provider nodes using k8s nodes for region
@@ -1471,7 +1471,7 @@ type gcpKey struct {
 	Labels map[string]string
 }
 
-func (gcp *GCP) GetKey(labels map[string]string, n *v1.Node) models.Key {
+func (gcp *GCP) GetKey(labels map[string]string, n *clustercache.Node) models.Key {
 	return &gcpKey{
 		Labels: labels,
 	}

+ 2 - 1
pkg/cloud/models/models.go

@@ -10,6 +10,7 @@ import (
 	"time"
 
 	"github.com/microcosm-cc/bluemonday"
+	"github.com/opencost/opencost/pkg/clustercache"
 	v1 "k8s.io/api/core/v1"
 
 	"github.com/opencost/opencost/core/pkg/log"
@@ -315,7 +316,7 @@ type Provider interface {
 	LoadBalancerPricing() (*LoadBalancer, error) // TODO: add key interface arg for dynamic price fetching
 	AllNodePricing() (interface{}, error)
 	DownloadPricingData() error
-	GetKey(map[string]string, *v1.Node) Key
+	GetKey(map[string]string, *clustercache.Node) Key
 	GetPVKey(*v1.PersistentVolume, map[string]string, string) PVKey
 	UpdateConfig(r io.Reader, updateType string) (*CustomPricing, error)
 	UpdateConfigFromConfigMap(map[string]string) (*CustomPricing, error)

+ 4 - 4
pkg/cloud/oracle/provider.go

@@ -125,7 +125,7 @@ func (o *Oracle) DownloadPricingData() error {
 	return nil
 }
 
-func (o *Oracle) GetKey(labels map[string]string, n *v1.Node) models.Key {
+func (o *Oracle) GetKey(labels map[string]string, n *clustercache.Node) models.Key {
 	var gpuCount int
 	var gpuType string
 	if gpuc, ok := n.Status.Capacity["nvidia.com/gpu"]; ok {
@@ -134,7 +134,7 @@ func (o *Oracle) GetKey(labels map[string]string, n *v1.Node) models.Key {
 	}
 	instanceType, _ := util.GetInstanceType(labels)
 	return &oracleKey{
-		providerID:   n.Spec.ProviderID,
+		providerID:   n.SpecProviderID,
 		instanceType: instanceType,
 		labels:       labels,
 		gpuCount:     gpuCount,
@@ -211,10 +211,10 @@ func (o *Oracle) GetConfig() (*models.CustomPricing, error) {
 func (o *Oracle) GetManagementPlatform() (string, error) {
 	nodes := o.Clientset.GetAllNodes()
 	for _, node := range nodes {
-		if _, ok := node.GetObjectMeta().GetAnnotations()[nodePoolIdAnnotation]; ok {
+		if _, ok := node.Annotations[nodePoolIdAnnotation]; ok {
 			return managementPlatformOKE, nil
 		}
-		if _, ok := node.GetObjectMeta().GetAnnotations()[virtualPoolIdAnnotation]; ok {
+		if _, ok := node.Annotations[virtualPoolIdAnnotation]; ok {
 			return managementPlatformOKE, nil
 		}
 	}

+ 4 - 5
pkg/cloud/oracle/provider_test.go

@@ -6,6 +6,7 @@ import (
 	"strings"
 	"testing"
 
+	"github.com/opencost/opencost/pkg/clustercache"
 	"github.com/stretchr/testify/assert"
 	v1 "k8s.io/api/core/v1"
 	"k8s.io/apimachinery/pkg/api/resource"
@@ -73,15 +74,13 @@ func TestGetPVKey(t *testing.T) {
 	assert.Equal(t, providerID, pvkey.ID())
 }
 
-func testNode(gpus int) *v1.Node {
+func testNode(gpus int) *clustercache.Node {
 	capacity := map[v1.ResourceName]resource.Quantity{}
 	if gpus > 0 {
 		capacity["nvidia.com/gpu"] = resource.MustParse(fmt.Sprintf("%d", gpus))
 	}
-	return &v1.Node{
-		Spec: v1.NodeSpec{
-			ProviderID: "ocid.abc",
-		},
+	return &clustercache.Node{
+		SpecProviderID: "ocid.abc",
 		Status: v1.NodeStatus{
 			Capacity: capacity,
 		},

+ 7 - 6
pkg/cloud/provider/csvprovider.go

@@ -13,6 +13,7 @@ import (
 
 	"github.com/opencost/opencost/core/pkg/util"
 	"github.com/opencost/opencost/pkg/cloud/models"
+	"github.com/opencost/opencost/pkg/clustercache"
 	"github.com/opencost/opencost/pkg/env"
 
 	"github.com/aws/aws-sdk-go/aws"
@@ -289,7 +290,7 @@ func (c *CSVProvider) NodePricing(key models.Key) (*models.Node, models.PricingM
 	return node, models.PricingMetadata{}, nil
 }
 
-func NodeValueFromMapField(m string, n *v1.Node, useRegion bool) string {
+func NodeValueFromMapField(m string, n *clustercache.Node, useRegion bool) string {
 	mf := strings.Split(m, ".")
 	toReturn := ""
 	if useRegion {
@@ -300,16 +301,16 @@ func NodeValueFromMapField(m string, n *v1.Node, useRegion bool) string {
 		}
 	}
 	if len(mf) == 2 && mf[0] == "spec" && mf[1] == "providerID" {
-		for matchNum, group := range provIdRx.FindStringSubmatch(n.Spec.ProviderID) {
+		for matchNum, group := range provIdRx.FindStringSubmatch(n.SpecProviderID) {
 			if matchNum == 2 {
 				return toReturn + group
 			}
 		}
-		if strings.HasPrefix(n.Spec.ProviderID, "azure://") {
-			vmOrScaleSet := strings.ToLower(strings.TrimPrefix(n.Spec.ProviderID, "azure://"))
+		if strings.HasPrefix(n.SpecProviderID, "azure://") {
+			vmOrScaleSet := strings.ToLower(strings.TrimPrefix(n.SpecProviderID, "azure://"))
 			return toReturn + vmOrScaleSet
 		}
-		return toReturn + n.Spec.ProviderID
+		return toReturn + n.SpecProviderID
 	} else if len(mf) > 1 && mf[0] == "metadata" {
 		if mf[1] == "name" {
 			return toReturn + n.Name
@@ -365,7 +366,7 @@ func PVValueFromMapField(m string, n *v1.PersistentVolume) string {
 	}
 }
 
-func (c *CSVProvider) GetKey(l map[string]string, n *v1.Node) models.Key {
+func (c *CSVProvider) GetKey(l map[string]string, n *clustercache.Node) models.Key {
 	id := NodeValueFromMapField(c.NodeMapField, n, c.UsesRegion)
 	var gpuCount int64
 	gpuCount = 0

+ 1 - 1
pkg/cloud/provider/customprovider.go

@@ -242,7 +242,7 @@ func (cp *CustomProvider) DownloadPricingData() error {
 	return nil
 }
 
-func (cp *CustomProvider) GetKey(labels map[string]string, n *v1.Node) models.Key {
+func (cp *CustomProvider) GetKey(labels map[string]string, n *clustercache.Node) models.Key {
 	return &customProviderKey{
 		SpotLabel:      cp.SpotLabel,
 		SpotLabelValue: cp.SpotLabelValue,

+ 2 - 4
pkg/cloud/provider/provider.go

@@ -27,8 +27,6 @@ import (
 	"github.com/opencost/opencost/pkg/clustercache"
 	"github.com/opencost/opencost/pkg/config"
 	"github.com/opencost/opencost/pkg/env"
-
-	v1 "k8s.io/api/core/v1"
 )
 
 // ClusterName returns the name defined in cluster info, defaulting to the
@@ -268,8 +266,8 @@ type clusterProperties struct {
 	projectID      string
 }
 
-func getClusterProperties(node *v1.Node) clusterProperties {
-	providerID := strings.ToLower(node.Spec.ProviderID)
+func getClusterProperties(node *clustercache.Node) clusterProperties {
+	providerID := strings.ToLower(node.SpecProviderID)
 	region, _ := util.GetRegion(node.Labels)
 	cp := clusterProperties{
 		provider:       "DEFAULT",

+ 1 - 1
pkg/cloud/scaleway/provider.go

@@ -181,7 +181,7 @@ func (c *Scaleway) NetworkPricing() (*models.Network, error) {
 	}, nil
 }
 
-func (c *Scaleway) GetKey(l map[string]string, n *v1.Node) models.Key {
+func (c *Scaleway) GetKey(l map[string]string, n *clustercache.Node) models.Key {
 	return &scalewayKey{
 		Labels: l,
 	}

+ 22 - 4
pkg/clustercache/clustercache.go

@@ -98,6 +98,24 @@ func transformPod(input *v1.Pod) *Pod {
 	}
 }
 
+type Node struct {
+	Name           string
+	Labels         map[string]string
+	Annotations    map[string]string
+	Status         v1.NodeStatus
+	SpecProviderID string
+}
+
+func transformNode(input *v1.Node) *Node {
+	return &Node{
+		Name:           input.Name,
+		Labels:         input.Labels,
+		Annotations:    input.Annotations,
+		Status:         input.Status,
+		SpecProviderID: input.Spec.ProviderID,
+	}
+}
+
 // ClusterCache defines an contract for an object which caches components within a cluster, ensuring
 // up to date resources using watchers
 type ClusterCache interface {
@@ -111,7 +129,7 @@ type ClusterCache interface {
 	GetAllNamespaces() []*Namespace
 
 	// GetAllNodes returns all the cached nodes
-	GetAllNodes() []*v1.Node
+	GetAllNodes() []*Node
 
 	// GetAllPods returns all the cached pods
 	GetAllPods() []*Pod
@@ -284,11 +302,11 @@ func (kcc *KubernetesClusterCache) GetAllNamespaces() []*Namespace {
 	return namespaces
 }
 
-func (kcc *KubernetesClusterCache) GetAllNodes() []*v1.Node {
-	var nodes []*v1.Node
+func (kcc *KubernetesClusterCache) GetAllNodes() []*Node {
+	var nodes []*Node
 	items := kcc.nodeWatch.GetAll()
 	for _, node := range items {
-		nodes = append(nodes, node.(*v1.Node))
+		nodes = append(nodes, transformNode(node.(*v1.Node)))
 	}
 	return nodes
 }

+ 4 - 4
pkg/costmodel/costmodel.go

@@ -1002,9 +1002,9 @@ func (cm *CostModel) GetNodeCost(cp costAnalyzerCloud.Provider) (map[string]*cos
 		PricingTypeCounts: make(map[costAnalyzerCloud.PricingType]int),
 	}
 	for _, n := range nodeList {
-		name := n.GetObjectMeta().GetName()
-		nodeLabels := n.GetObjectMeta().GetLabels()
-		nodeLabels["providerID"] = n.Spec.ProviderID
+		name := n.Name
+		nodeLabels := n.Labels
+		nodeLabels["providerID"] = n.SpecProviderID
 
 		pmd.TotalNodes++
 
@@ -1041,7 +1041,7 @@ func (cm *CostModel) GetNodeCost(cp costAnalyzerCloud.Provider) (map[string]*cos
 			arch, _ := util.GetArchType(n.Labels)
 			newCnode.ArchType = arch
 		}
-		newCnode.ProviderID = n.Spec.ProviderID
+		newCnode.ProviderID = n.SpecProviderID
 
 		var cpu float64
 		if newCnode.VCPU == "" {

+ 2 - 2
pkg/metrics/nodemetrics.go

@@ -62,7 +62,7 @@ func (nsac KubeNodeCollector) Collect(ch chan<- prometheus.Metric) {
 	disabledMetrics := nsac.metricsConfig.GetDisabledMetricsMap()
 
 	for _, node := range nodes {
-		nodeName := node.GetName()
+		nodeName := node.Name
 
 		// Node Capacity
 		for resourceName, quantity := range node.Status.Capacity {
@@ -120,7 +120,7 @@ func (nsac KubeNodeCollector) Collect(ch chan<- prometheus.Metric) {
 
 		// node labels
 		if _, disabled := disabledMetrics["kube_node_labels"]; !disabled {
-			labelNames, labelValues := promutil.KubePrependQualifierToLabels(promutil.SanitizeLabels(node.GetLabels()), "label_")
+			labelNames, labelValues := promutil.KubePrependQualifierToLabels(promutil.SanitizeLabels(node.Labels), "label_")
 			ch <- newKubeNodeLabelsMetric(nodeName, "kube_node_labels", labelNames, labelValues)
 		}
 

+ 48 - 48
test/cloud_test.go

@@ -33,8 +33,8 @@ func TestRegionValueFromMapField(t *testing.T) {
 	wantpid := strings.ToLower("/subscriptions/0bd50fdf-c923-4e1e-850c-196dd3dcc5d3/resourceGroups/MC_test_test_eastus/providers/Microsoft.Compute/virtualMachines/aks-agentpool-20139558-0")
 	providerIDWant := wantRegion + "," + wantpid
 
-	n := &v1.Node{}
-	n.Spec.ProviderID = "azure:///subscriptions/0bd50fdf-c923-4e1e-850c-196dd3dcc5d3/resourceGroups/MC_test_test_eastus/providers/Microsoft.Compute/virtualMachines/aks-agentpool-20139558-0"
+	n := &clustercache.Node{}
+	n.SpecProviderID = "azure:///subscriptions/0bd50fdf-c923-4e1e-850c-196dd3dcc5d3/resourceGroups/MC_test_test_eastus/providers/Microsoft.Compute/virtualMachines/aks-agentpool-20139558-0"
 	n.Labels = make(map[string]string)
 	n.Labels[v1.LabelTopologyRegion] = wantRegion
 	got := provider.NodeValueFromMapField(providerIDMap, n, true)
@@ -45,24 +45,24 @@ func TestRegionValueFromMapField(t *testing.T) {
 }
 func TestTransformedValueFromMapField(t *testing.T) {
 	providerIDWant := "i-05445591e0d182d42"
-	n := &v1.Node{}
-	n.Spec.ProviderID = "aws:///us-east-1a/i-05445591e0d182d42"
+	n := &clustercache.Node{}
+	n.SpecProviderID = "aws:///us-east-1a/i-05445591e0d182d42"
 	got := provider.NodeValueFromMapField(providerIDMap, n, false)
 	if got != providerIDWant {
 		t.Errorf("Assert on '%s' want '%s' got '%s'", providerIDMap, providerIDWant, got)
 	}
 
 	providerIDWant2 := strings.ToLower("/subscriptions/0bd50fdf-c923-4e1e-850c-196dd3dcc5d3/resourceGroups/MC_test_test_eastus/providers/Microsoft.Compute/virtualMachines/aks-agentpool-20139558-0")
-	n2 := &v1.Node{}
-	n2.Spec.ProviderID = "azure:///subscriptions/0bd50fdf-c923-4e1e-850c-196dd3dcc5d3/resourceGroups/MC_test_test_eastus/providers/Microsoft.Compute/virtualMachines/aks-agentpool-20139558-0"
+	n2 := &clustercache.Node{}
+	n2.SpecProviderID = "azure:///subscriptions/0bd50fdf-c923-4e1e-850c-196dd3dcc5d3/resourceGroups/MC_test_test_eastus/providers/Microsoft.Compute/virtualMachines/aks-agentpool-20139558-0"
 	got2 := provider.NodeValueFromMapField(providerIDMap, n2, false)
 	if got2 != providerIDWant2 {
 		t.Errorf("Assert on '%s' want '%s' got '%s'", providerIDMap, providerIDWant2, got2)
 	}
 
 	providerIDWant3 := strings.ToLower("/subscriptions/0bd50fdf-c923-4e1e-850c-196dd3dcc5d3/resourceGroups/mc_testspot_testspot_eastus/providers/Microsoft.Compute/virtualMachineScaleSets/aks-nodepool1-19213364-vmss/virtualMachines/0")
-	n3 := &v1.Node{}
-	n3.Spec.ProviderID = "azure:///subscriptions/0bd50fdf-c923-4e1e-850c-196dd3dcc5d3/resourceGroups/mc_testspot_testspot_eastus/providers/Microsoft.Compute/virtualMachineScaleSets/aks-nodepool1-19213364-vmss/virtualMachines/0"
+	n3 := &clustercache.Node{}
+	n3.SpecProviderID = "azure:///subscriptions/0bd50fdf-c923-4e1e-850c-196dd3dcc5d3/resourceGroups/mc_testspot_testspot_eastus/providers/Microsoft.Compute/virtualMachineScaleSets/aks-nodepool1-19213364-vmss/virtualMachines/0"
 	got3 := provider.NodeValueFromMapField(providerIDMap, n3, false)
 	if got3 != providerIDWant3 {
 		t.Errorf("Assert on '%s' want '%s' got '%s'", providerIDMap, providerIDWant3, got3)
@@ -74,8 +74,8 @@ func TestNodeValueFromMapField(t *testing.T) {
 	nameWant := "gke-standard-cluster-1-pool-1-91dc432d-cg69"
 	labelFooWant := "labelfoo"
 
-	n := &v1.Node{}
-	n.Spec.ProviderID = providerIDWant
+	n := &clustercache.Node{}
+	n.SpecProviderID = providerIDWant
 	n.Name = nameWant
 	n.Labels = make(map[string]string)
 	n.Labels["foo"] = labelFooWant
@@ -173,8 +173,8 @@ func TestNodePriceFromCSVWithGPU(t *testing.T) {
 		LocalConfigPath: "./",
 	})
 
-	n := &v1.Node{}
-	n.Spec.ProviderID = providerIDWant
+	n := &clustercache.Node{}
+	n.SpecProviderID = providerIDWant
 	n.Name = nameWant
 	n.Labels = make(map[string]string)
 	n.Labels["foo"] = labelFooWant
@@ -182,8 +182,8 @@ func TestNodePriceFromCSVWithGPU(t *testing.T) {
 	n.Status.Capacity = v1.ResourceList{"nvidia.com/gpu": *resource.NewScaledQuantity(2, 0)}
 	wantPrice := "1.633700"
 
-	n2 := &v1.Node{}
-	n2.Spec.ProviderID = providerIDWant
+	n2 := &clustercache.Node{}
+	n2.SpecProviderID = providerIDWant
 	n2.Name = nameWant
 	n2.Labels = make(map[string]string)
 	n2.Labels["foo"] = labelFooWant
@@ -244,7 +244,7 @@ func TestNodePriceFromCSVSpecialChar(t *testing.T) {
 		LocalConfigPath: "./",
 	})
 
-	n := &v1.Node{}
+	n := &clustercache.Node{}
 	n.Name = nameWant
 	n.Labels = make(map[string]string)
 	n.Labels["<http://metadata.label.servers.com/label|metadata.label.servers.com/label>"] = nameWant
@@ -281,8 +281,8 @@ func TestNodePriceFromCSV(t *testing.T) {
 		LocalConfigPath: "./",
 	})
 
-	n := &v1.Node{}
-	n.Spec.ProviderID = providerIDWant
+	n := &clustercache.Node{}
+	n.SpecProviderID = providerIDWant
 	n.Name = nameWant
 	n.Labels = make(map[string]string)
 	n.Labels["foo"] = labelFooWant
@@ -309,8 +309,8 @@ func TestNodePriceFromCSV(t *testing.T) {
 		}
 	}
 
-	unknownN := &v1.Node{}
-	unknownN.Spec.ProviderID = providerIDWant
+	unknownN := &clustercache.Node{}
+	unknownN.SpecProviderID = providerIDWant
 	unknownN.Name = "unknownname"
 	unknownN.Labels = make(map[string]string)
 	unknownN.Labels["foo"] = labelFooWant
@@ -343,24 +343,24 @@ func TestNodePriceFromCSVWithRegion(t *testing.T) {
 		LocalConfigPath: "./",
 	})
 
-	n := &v1.Node{}
-	n.Spec.ProviderID = providerIDWant
+	n := &clustercache.Node{}
+	n.SpecProviderID = providerIDWant
 	n.Name = nameWant
 	n.Labels = make(map[string]string)
 	n.Labels["foo"] = labelFooWant
 	n.Labels[v1.LabelTopologyRegion] = "regionone"
 	wantPrice := "0.133700"
 
-	n2 := &v1.Node{}
-	n2.Spec.ProviderID = providerIDWant
+	n2 := &clustercache.Node{}
+	n2.SpecProviderID = providerIDWant
 	n2.Name = nameWant
 	n2.Labels = make(map[string]string)
 	n2.Labels["foo"] = labelFooWant
 	n2.Labels[v1.LabelTopologyRegion] = "regiontwo"
 	wantPrice2 := "0.133800"
 
-	n3 := &v1.Node{}
-	n3.Spec.ProviderID = providerIDWant
+	n3 := &clustercache.Node{}
+	n3.SpecProviderID = providerIDWant
 	n3.Name = nameWant
 	n3.Labels = make(map[string]string)
 	n3.Labels["foo"] = labelFooWant
@@ -411,8 +411,8 @@ func TestNodePriceFromCSVWithRegion(t *testing.T) {
 		}
 	}
 
-	unknownN := &v1.Node{}
-	unknownN.Spec.ProviderID = "fake providerID"
+	unknownN := &clustercache.Node{}
+	unknownN.SpecProviderID = "fake providerID"
 	unknownN.Name = "unknownname"
 	unknownN.Labels = make(map[string]string)
 	unknownN.Labels[v1.LabelTopologyRegion] = "fakeregion"
@@ -437,11 +437,11 @@ func TestNodePriceFromCSVWithRegion(t *testing.T) {
 }
 
 type FakeCache struct {
-	nodes []*v1.Node
+	nodes []*clustercache.Node
 	clustercache.ClusterCache
 }
 
-func (f FakeCache) GetAllNodes() []*v1.Node {
+func (f FakeCache) GetAllNodes() []*clustercache.Node {
 	return f.nodes
 }
 
@@ -449,7 +449,7 @@ func (f FakeCache) GetAllDaemonSets() []*appsv1.DaemonSet {
 	return nil
 }
 
-func NewFakeNodeCache(nodes []*v1.Node) FakeCache {
+func NewFakeNodeCache(nodes []*clustercache.Node) FakeCache {
 	return FakeCache{
 		nodes: nodes,
 	}
@@ -473,14 +473,14 @@ func TestNodePriceFromCSVWithBadConfig(t *testing.T) {
 	}
 	c.DownloadPricingData()
 
-	n := &v1.Node{}
-	n.Spec.ProviderID = "fake"
+	n := &clustercache.Node{}
+	n.SpecProviderID = "fake"
 	n.Name = "nameWant"
 	n.Labels = make(map[string]string)
 	n.Labels["foo"] = "labelFooWant"
 	n.Labels[v1.LabelTopologyRegion] = "regionone"
 
-	fc := NewFakeNodeCache([]*v1.Node{n})
+	fc := NewFakeNodeCache([]*clustercache.Node{n})
 	fm := FakeClusterMap{}
 	d, _ := time.ParseDuration("1m")
 
@@ -507,15 +507,15 @@ func TestSourceMatchesFromCSV(t *testing.T) {
 	}
 	c.DownloadPricingData()
 
-	n := &v1.Node{}
-	n.Spec.ProviderID = "fake"
+	n := &clustercache.Node{}
+	n.SpecProviderID = "fake"
 	n.Name = "nameWant"
 	n.Labels = make(map[string]string)
 	n.Labels["foo"] = "labelFooWant"
 	n.Labels[v1.LabelTopologyRegion] = "regionone"
 
-	n2 := &v1.Node{}
-	n2.Spec.ProviderID = "azure:///subscriptions/123a7sd-asd-1234-578a9-123abcdef/resourceGroups/case_12_STaGe_TeSt7/providers/Microsoft.Compute/virtualMachineScaleSets/vmss-agent-worker0-12stagetest7-ezggnore/virtualMachines/7"
+	n2 := &clustercache.Node{}
+	n2.SpecProviderID = "azure:///subscriptions/123a7sd-asd-1234-578a9-123abcdef/resourceGroups/case_12_STaGe_TeSt7/providers/Microsoft.Compute/virtualMachineScaleSets/vmss-agent-worker0-12stagetest7-ezggnore/virtualMachines/7"
 	n2.Labels = make(map[string]string)
 	n2.Labels[v1.LabelTopologyRegion] = "eastus2"
 	n2.Labels["foo"] = "labelFooWant"
@@ -532,14 +532,14 @@ func TestSourceMatchesFromCSV(t *testing.T) {
 		}
 	}
 
-	n3 := &v1.Node{}
-	n3.Spec.ProviderID = "fake"
+	n3 := &clustercache.Node{}
+	n3.SpecProviderID = "fake"
 	n3.Name = "nameWant"
 	n3.Labels = make(map[string]string)
 	n3.Labels[v1.LabelTopologyRegion] = "eastus2"
 	n3.Labels[v1.LabelInstanceTypeStable] = "Standard_F32s_v2"
 
-	fc := NewFakeNodeCache([]*v1.Node{n, n2, n3})
+	fc := NewFakeNodeCache([]*clustercache.Node{n, n2, n3})
 	fm := FakeClusterMap{}
 	d, _ := time.ParseDuration("1m")
 
@@ -568,8 +568,8 @@ func TestSourceMatchesFromCSV(t *testing.T) {
 }
 
 func TestNodePriceFromCSVWithCase(t *testing.T) {
-	n := &v1.Node{}
-	n.Spec.ProviderID = "azure:///subscriptions/123a7sd-asd-1234-578a9-123abcdef/resourceGroups/case_12_STaGe_TeSt7/providers/Microsoft.Compute/virtualMachineScaleSets/vmss-agent-worker0-12stagetest7-ezggnore/virtualMachines/7"
+	n := &clustercache.Node{}
+	n.SpecProviderID = "azure:///subscriptions/123a7sd-asd-1234-578a9-123abcdef/resourceGroups/case_12_STaGe_TeSt7/providers/Microsoft.Compute/virtualMachineScaleSets/vmss-agent-worker0-12stagetest7-ezggnore/virtualMachines/7"
 	n.Labels = make(map[string]string)
 	n.Labels[v1.LabelTopologyRegion] = "eastus2"
 	wantPrice := "0.13370357"
@@ -608,7 +608,7 @@ func TestNodePriceFromCSVMixed(t *testing.T) {
 		LocalConfigPath: "./",
 	})
 
-	n := &v1.Node{}
+	n := &clustercache.Node{}
 	n.Labels = make(map[string]string)
 	n.Labels["TestClusterUsage"] = labelFooWant
 	n.Labels["nvidia.com/gpu_type"] = "a100-ondemand"
@@ -616,7 +616,7 @@ func TestNodePriceFromCSVMixed(t *testing.T) {
 	wantPrice := "1.904110"
 
 	labelFooWant2 := "Reserved"
-	n2 := &v1.Node{}
+	n2 := &clustercache.Node{}
 	n2.Labels = make(map[string]string)
 	n2.Labels["TestClusterUsage"] = labelFooWant2
 	n2.Labels["nvidia.com/gpu_type"] = "a100-reserved"
@@ -659,8 +659,8 @@ func TestNodePriceFromCSVMixed(t *testing.T) {
 }
 
 func TestNodePriceFromCSVByClass(t *testing.T) {
-	n := &v1.Node{}
-	n.Spec.ProviderID = "fakeproviderid"
+	n := &clustercache.Node{}
+	n.SpecProviderID = "fakeproviderid"
 	n.Labels = make(map[string]string)
 	n.Labels[v1.LabelTopologyRegion] = "eastus2"
 	n.Labels[v1.LabelInstanceTypeStable] = "Standard_F32s_v2"
@@ -691,8 +691,8 @@ func TestNodePriceFromCSVByClass(t *testing.T) {
 		}
 	}
 
-	n2 := &v1.Node{}
-	n2.Spec.ProviderID = "fakeproviderid"
+	n2 := &clustercache.Node{}
+	n2.SpecProviderID = "fakeproviderid"
 	n2.Labels = make(map[string]string)
 	n2.Labels[v1.LabelTopologyRegion] = "fakeregion"
 	n2.Labels[v1.LabelInstanceTypeStable] = "Standard_F32s_v2"