Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cherry-pick to 1.26]: implement function to identify if node is present in aws #5787

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions cluster-autoscaler/cloudprovider/aws/aws_cloud_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,19 @@ func (aws *awsCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovider.N
}

// HasInstance returns whether a given node has a corresponding instance in this cloud provider
func (aws *awsCloudProvider) HasInstance(*apiv1.Node) (bool, error) {
return true, cloudprovider.ErrNotImplemented
func (aws *awsCloudProvider) HasInstance(node *apiv1.Node) (bool, error) {
awsRef, err := AwsRefFromProviderId(node.Spec.ProviderID)
if err != nil {
return false, err
}

// we don't care about the status
status, err := aws.awsManager.asgCache.InstanceStatus(*awsRef)
if status != nil {
return true, nil
}

return false, fmt.Errorf("node is not present in aws: %v", err)
}

// Pricing returns pricing model for this cloud provider or error if not available.
Expand Down