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 <[email protected]>
  • Loading branch information
vadasambar committed Mar 23, 2023
1 parent 1931ea6 commit 4dcbc14
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cluster-autoscaler/cloudprovider/aws/aws_cloud_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,18 @@ 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 instance health
if _, ok := aws.awsManager.asgCache.instanceStatus[*awsRef]; !ok {
return false, fmt.Errorf("node isn't present in aws")
}

return true, nil
}

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

0 comments on commit 4dcbc14

Please sign in to comment.