Skip to content

Commit

Permalink
Merge pull request #5785 from vadasambar/fix/4456/cherry-pick-1.24-id…
Browse files Browse the repository at this point in the history
…entify-deleted-nodes-for-aws

[cherry-pick to 1.24]: implement function to identify if node is present in aws
  • Loading branch information
k8s-ci-robot authored May 22, 2023
2 parents 021d5ff + 40d34d2 commit 16131db
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cluster-autoscaler/cloudprovider/aws/aws_cloud_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,22 @@ func (aws *awsCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovider.N
}, nil
}

// HasInstance returns whether a given node has a corresponding instance in this cloud provider
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.
func (aws *awsCloudProvider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError) {
return nil, cloudprovider.ErrNotImplemented
Expand Down

0 comments on commit 16131db

Please sign in to comment.