Skip to content

Commit

Permalink
fix: implement function to identify if node is present in aws
Browse files Browse the repository at this point in the history
- this is a follow-up to kubernetes#5054
- this might fix kubernetes#4456

fix: make `HasInstance` in aws provider thread-safe

Signed-off-by: vadasambar <[email protected]>
(cherry picked from commit 1cb55fe)
  • Loading branch information
vadasambar committed May 22, 2023
1 parent 92df13d commit 0319538
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 @@ -120,6 +120,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 0319538

Please sign in to comment.