Skip to content

Commit

Permalink
Merge pull request kubernetes#6708 from MaxFedotov/fix/4456/identify-…
Browse files Browse the repository at this point in the history
…deleted-nodes-for-cluster-api

fix: implement function to identify if node is present in cluster-api
  • Loading branch information
k8s-ci-robot authored Apr 23, 2024
2 parents 349559c + 8c7fe0f commit 5135f24
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package clusterapi

import (
"fmt"
"reflect"

corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -84,7 +85,14 @@ func (p *provider) NodeGroupForNode(node *corev1.Node) (cloudprovider.NodeGroup,

// HasInstance returns whether a given node has a corresponding instance in this cloud provider
func (p *provider) HasInstance(node *corev1.Node) (bool, error) {
return true, cloudprovider.ErrNotImplemented
machineID := node.Annotations[machineAnnotationKey]

machine, err := p.controller.findMachine(machineID)
if machine != nil {
return true, nil
}

return false, fmt.Errorf("machine not found for node %s: %v", node.Name, err)
}

func (*provider) Pricing() (cloudprovider.PricingModel, errors.AutoscalerError) {
Expand Down

0 comments on commit 5135f24

Please sign in to comment.