From 1e4cb18fb2d1028b79b740ac657116fe63533279 Mon Sep 17 00:00:00 2001 From: Ayush Rangwala Date: Mon, 23 Oct 2023 17:35:07 +0530 Subject: [PATCH] fix: refactor cloud provider names Signed-off-by: Ayush Rangwala --- .../cloudprovider/builder/builder_all.go | 3 +-- .../cloudprovider/builder/builder_packet.go | 7 +++---- .../cloudprovider/packet/packet_cloud_provider.go | 12 +++++++----- .../cloudprovider/packet/packet_node_group_test.go | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cluster-autoscaler/cloudprovider/builder/builder_all.go b/cluster-autoscaler/cloudprovider/builder/builder_all.go index dfcd001ba55f..1398b5ad95b9 100644 --- a/cluster-autoscaler/cloudprovider/builder/builder_all.go +++ b/cluster-autoscaler/cloudprovider/builder/builder_all.go @@ -121,8 +121,7 @@ func buildCloudProvider(opts config.AutoscalingOptions, do cloudprovider.NodeGro return ovhcloud.BuildOVHcloud(opts, do, rl) case cloudprovider.HetznerProviderName: return hetzner.BuildHetzner(opts, do, rl) - case cloudprovider.PacketProviderName, - cloudprovider.EquinixMetalProviderName: + case cloudprovider.PacketProviderName, cloudprovider.EquinixMetalProviderName: return packet.BuildCloudProvider(opts, do, rl) case cloudprovider.ClusterAPIProviderName: return clusterapi.BuildClusterAPI(opts, do, rl) diff --git a/cluster-autoscaler/cloudprovider/builder/builder_packet.go b/cluster-autoscaler/cloudprovider/builder/builder_packet.go index bd7bb3c2e542..e41d743dd570 100644 --- a/cluster-autoscaler/cloudprovider/builder/builder_packet.go +++ b/cluster-autoscaler/cloudprovider/builder/builder_packet.go @@ -28,16 +28,15 @@ import ( // AvailableCloudProviders supported by the cloud provider builder. var AvailableCloudProviders = []string{ packet.ProviderName, - packet.EquinixMetalProviderName, + cloudprovider.EquinixMetalProviderName, } // DefaultCloudProvider for Packet-only build is Packet. -const DefaultCloudProvider = packet.EquinixMetalProviderName +const DefaultCloudProvider = cloudprovider.EquinixMetalProviderName func buildCloudProvider(opts config.AutoscalingOptions, do cloudprovider.NodeGroupDiscoveryOptions, rl *cloudprovider.ResourceLimiter) cloudprovider.CloudProvider { switch opts.CloudProviderName { - case packet.ProviderName, - packet.EquinixMetalProviderName: + case packet.ProviderName, cloudprovider.EquinixMetalProviderName: return packet.BuildCloudProvider(opts, do, rl) } diff --git a/cluster-autoscaler/cloudprovider/packet/packet_cloud_provider.go b/cluster-autoscaler/cloudprovider/packet/packet_cloud_provider.go index 4ac984952719..fbb5a96d0c30 100644 --- a/cluster-autoscaler/cloudprovider/packet/packet_cloud_provider.go +++ b/cluster-autoscaler/cloudprovider/packet/packet_cloud_provider.go @@ -25,17 +25,18 @@ import ( apiv1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" + klog "k8s.io/klog/v2" + "k8s.io/autoscaler/cluster-autoscaler/cloudprovider" "k8s.io/autoscaler/cluster-autoscaler/config" "k8s.io/autoscaler/cluster-autoscaler/config/dynamic" "k8s.io/autoscaler/cluster-autoscaler/utils/errors" "k8s.io/autoscaler/cluster-autoscaler/utils/gpu" - klog "k8s.io/klog/v2" ) const ( - // ProviderName is the cloud provider name for Equinix Metal - ProviderName = "equinix-metal" + // ProviderName is the cloud provider name for Packet cloud provider, now named as equinixmetal + ProviderName = "packet" // GPULabel is the label added to nodes with GPU resource. GPULabel = "cloud.google.com/gke-accelerator" // DefaultControllerNodeLabelKey is the label added to Master/Controller to identify as @@ -44,7 +45,8 @@ const ( // ControllerNodeIdentifierEnv is the string for the environment variable. // Deprecated: This env var is deprecated in the favour packet's acquisition to equinix. // Please use 'ControllerNodeIdentifierMetalEnv' - ControllerNodeIdentifierEnv = "PACKET_CONTROLLER_NODE_IDENTIFIER_LABEL" + ControllerNodeIdentifierEnv = "PACKET_CONTROLLER_NODE_IDENTIFIER_LABEL" + // ControllerNodeIdentifierMetalEnv is the string for the environment variable of controller node id labels for equinix metal. ControllerNodeIdentifierMetalEnv = "METAL_CONTROLLER_NODE_IDENTIFIER_LABEL" ) @@ -72,7 +74,7 @@ func buildEquinixMetalCloudProvider(metalManager equinixMetalManager, resourceLi // Name returns the name of the cloud provider. func (pcp *equinixMetalCloudProvider) Name() string { - return ProviderName + return cloudprovider.EquinixMetalProviderName } // GPULabel returns the label added to nodes with GPU resource. diff --git a/cluster-autoscaler/cloudprovider/packet/packet_node_group_test.go b/cluster-autoscaler/cloudprovider/packet/packet_node_group_test.go index 9f8e514047a8..56819727ee03 100644 --- a/cluster-autoscaler/cloudprovider/packet/packet_node_group_test.go +++ b/cluster-autoscaler/cloudprovider/packet/packet_node_group_test.go @@ -42,7 +42,7 @@ func TestIncreaseDecreaseSize(t *testing.T) { assert.Equal(t, true, true) if len(os.Getenv("PACKET_AUTH_TOKEN")) > 0 || len(os.Getenv(metalAuthTokenEnv)) > 0 { // If auth token set in env, hit the actual Packet API - m = newTestMetalManagerRest(t, "https://api.equinix.com") + m = newTestMetalManagerRest(t, "https://api.equinix.com/metal/v1") } else { // Set up a mock Packet API m = newTestMetalManagerRest(t, server.URL)