Skip to content

Commit

Permalink
fix: refactor cloud provider names
Browse files Browse the repository at this point in the history
Signed-off-by: Ayush Rangwala <[email protected]>
  • Loading branch information
aayushrangwala committed Oct 23, 2023
1 parent 0d84ab6 commit 1e4cb18
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
3 changes: 1 addition & 2 deletions cluster-autoscaler/cloudprovider/builder/builder_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 3 additions & 4 deletions cluster-autoscaler/cloudprovider/builder/builder_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
12 changes: 7 additions & 5 deletions cluster-autoscaler/cloudprovider/packet/packet_cloud_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
)

Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1e4cb18

Please sign in to comment.