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

Signed-off-by: vadasambar <suraj.bankar@acquia.com>

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

Signed-off-by: vadasambar <suraj.bankar@acquia.com>
(cherry picked from commit 1cb55fe)
  • Loading branch information
vadasambar committed May 22, 2023
1 parent 4922c8b commit c008ff0
Showing 1 changed file with 13 additions and 2 deletions.
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

0 comments on commit c008ff0

Please sign in to comment.