diff --git a/cluster-autoscaler/cloudprovider/alicloud/alicloud_cloud_provider.go b/cluster-autoscaler/cloudprovider/alicloud/alicloud_cloud_provider.go index 07c8a7a6bcea..d3dcdbc838d1 100644 --- a/cluster-autoscaler/cloudprovider/alicloud/alicloud_cloud_provider.go +++ b/cluster-autoscaler/cloudprovider/alicloud/alicloud_cloud_provider.go @@ -140,6 +140,11 @@ func (ali *aliCloudProvider) Cleanup() error { return nil } +// GetInstanceID gets the instance ID for the specified node. +func (ali *aliCloudProvider) GetInstanceID(node *apiv1.Node) string { + return node.Spec.ProviderID +} + // AliRef contains a reference to ECS instance or . type AliRef struct { ID string diff --git a/cluster-autoscaler/cloudprovider/aws/aws_cloud_provider.go b/cluster-autoscaler/cloudprovider/aws/aws_cloud_provider.go index bddecab4ed9b..62fe61845771 100644 --- a/cluster-autoscaler/cloudprovider/aws/aws_cloud_provider.go +++ b/cluster-autoscaler/cloudprovider/aws/aws_cloud_provider.go @@ -127,6 +127,11 @@ func (aws *awsCloudProvider) Refresh() error { return aws.awsManager.Refresh() } +// GetInstanceID gets the instance ID for the specified node. +func (aws *awsCloudProvider) GetInstanceID(node *apiv1.Node) string { + return node.Spec.ProviderID +} + // AwsRef contains a reference to some entity in AWS world. type AwsRef struct { Name string diff --git a/cluster-autoscaler/cloudprovider/baiducloud/baiducloud_cloud_provider.go b/cluster-autoscaler/cloudprovider/baiducloud/baiducloud_cloud_provider.go index f99e60c131f5..d6e16efd4be6 100644 --- a/cluster-autoscaler/cloudprovider/baiducloud/baiducloud_cloud_provider.go +++ b/cluster-autoscaler/cloudprovider/baiducloud/baiducloud_cloud_provider.go @@ -196,6 +196,11 @@ func (baiducloud *baiducloudCloudProvider) Refresh() error { return nil } +// GetInstanceID gets the instance ID for the specified node. +func (baiducloud *baiducloudCloudProvider) GetInstanceID(node *apiv1.Node) string { + return node.Spec.ProviderID +} + // BaiducloudRef contains a reference to some entity in baiducloud world. type BaiducloudRef struct { Name string diff --git a/cluster-autoscaler/cloudprovider/gce/gce_cloud_provider.go b/cluster-autoscaler/cloudprovider/gce/gce_cloud_provider.go index 7741c612809c..80974b37c671 100644 --- a/cluster-autoscaler/cloudprovider/gce/gce_cloud_provider.go +++ b/cluster-autoscaler/cloudprovider/gce/gce_cloud_provider.go @@ -114,6 +114,11 @@ func (gce *GceCloudProvider) Refresh() error { return gce.gceManager.Refresh() } +// GetInstanceID gets the instance ID for the specified node. +func (gce *GceCloudProvider) GetInstanceID(node *apiv1.Node) string { + return node.Spec.ProviderID +} + // GceRef contains s reference to some entity in GCE world. type GceRef struct { Project string diff --git a/cluster-autoscaler/cloudprovider/gke/gke_cloud_provider.go b/cluster-autoscaler/cloudprovider/gke/gke_cloud_provider.go index a6ce8f3b3f55..76cc7fb8d68a 100644 --- a/cluster-autoscaler/cloudprovider/gke/gke_cloud_provider.go +++ b/cluster-autoscaler/cloudprovider/gke/gke_cloud_provider.go @@ -213,6 +213,11 @@ func (gke *GkeCloudProvider) GetNodeLocations() []string { return gke.gkeManager.GetNodeLocations() } +// GetInstanceID gets the instance ID for the specified node. +func (gke *GkeCloudProvider) GetInstanceID(node *apiv1.Node) string { + return node.Spec.ProviderID +} + // MigSpec contains information about what machines in a MIG look like. type MigSpec struct { MachineType string diff --git a/cluster-autoscaler/cloudprovider/kubemark/kubemark_linux.go b/cluster-autoscaler/cloudprovider/kubemark/kubemark_linux.go index 8b556cf66628..eddeeb13c7ae 100644 --- a/cluster-autoscaler/cloudprovider/kubemark/kubemark_linux.go +++ b/cluster-autoscaler/cloudprovider/kubemark/kubemark_linux.go @@ -135,6 +135,11 @@ func (kubemark *KubemarkCloudProvider) Refresh() error { return nil } +// GetInstanceID gets the instance ID for the specified node. +func (kubemark *KubemarkCloudProvider) GetInstanceID(node *apiv1.Node) string { + return node.Spec.ProviderID +} + // Cleanup cleans up all resources before the cloud provider is removed func (kubemark *KubemarkCloudProvider) Cleanup() error { return nil diff --git a/cluster-autoscaler/cloudprovider/kubemark/kubemark_other.go b/cluster-autoscaler/cloudprovider/kubemark/kubemark_other.go index f7b0afd32cbc..47af42565659 100644 --- a/cluster-autoscaler/cloudprovider/kubemark/kubemark_other.go +++ b/cluster-autoscaler/cloudprovider/kubemark/kubemark_other.go @@ -85,6 +85,11 @@ func (kubemark *KubemarkCloudProvider) Refresh() error { return cloudprovider.ErrNotImplemented } +// GetInstanceID gets the instance ID for the specified node. +func (kubemark *KubemarkCloudProvider) GetInstanceID(node *apiv1.Node) string { + return "" +} + // Cleanup cleans up all resources before the cloud provider is removed func (kubemark *KubemarkCloudProvider) Cleanup() error { return cloudprovider.ErrNotImplemented diff --git a/cluster-autoscaler/cloudprovider/mocks/CloudProvider.go b/cluster-autoscaler/cloudprovider/mocks/CloudProvider.go index 6a6c9d948d2f..ce4cdd186f91 100644 --- a/cluster-autoscaler/cloudprovider/mocks/CloudProvider.go +++ b/cluster-autoscaler/cloudprovider/mocks/CloudProvider.go @@ -201,3 +201,17 @@ func (_m *CloudProvider) Refresh() error { return r0 } + +// GetInstanceID gets the instance ID for the specified node. +func (_m *CloudProvider) GetInstanceID(node *v1.Node) string { + ret := _m.Called() + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} diff --git a/cluster-autoscaler/cloudprovider/test/test_cloud_provider.go b/cluster-autoscaler/cloudprovider/test/test_cloud_provider.go index 92818131e82e..97e2a65a5dff 100644 --- a/cluster-autoscaler/cloudprovider/test/test_cloud_provider.go +++ b/cluster-autoscaler/cloudprovider/test/test_cloud_provider.go @@ -224,6 +224,11 @@ func (tcp *TestCloudProvider) Refresh() error { return nil } +// GetInstanceID gets the instance ID for the specified node. +func (tcp *TestCloudProvider) GetInstanceID(node *apiv1.Node) string { + return node.Spec.ProviderID +} + // TestNodeGroup is a node group used by TestCloudProvider. type TestNodeGroup struct { sync.Mutex