Skip to content

Commit

Permalink
Adding check to backfill loop to confirm cloud provider node no longe…
Browse files Browse the repository at this point in the history
…r exists before flagging the node as deleted. Modifying some comments to be more accurate. Replacing erroneous line deletion.
  • Loading branch information
fookenc committed Aug 12, 2022
1 parent 2697639 commit 48b6328
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cluster-autoscaler/clusterstate/clusterstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ func (csr *ClusterStateRegistry) UpdateNodes(nodes []*apiv1.Node, nodeInfosForGr
return err
}
notRegistered := getNotRegisteredNodes(nodes, cloudProviderNodeInstances, currentTime)

csr.Lock()
defer csr.Unlock()

Expand Down Expand Up @@ -1000,19 +1001,22 @@ func (csr *ClusterStateRegistry) getCloudProviderDeletedNodes(allNodes []*apiv1.

// Fill previously deleted nodes, if they are still registered in Kubernetes
for nodeName, node := range csr.deletedNodes {
if _, found := registeredNodes[nodeName]; found {
// Safety check to prevent flagging Kubernetes nodes as deleted
// if the Cloud Provider instance is re-discovered
_, cloudProviderFound := currentCloudInstances[node.Name]
if _, found := registeredNodes[nodeName]; found && !cloudProviderFound {
nodesRemoved = append(nodesRemoved, node)
}
}

// Seek nodes that may have been deleted since last update
// cloudProviderNodeInstances are retrieved by nodeGroup,
// not autoscaled nodes will not be included
// not autoscaled nodes will be excluded
for _, instances := range csr.cloudProviderNodeInstances {
for _, instance := range instances {
if _, found := currentCloudInstances[instance.Id]; !found {
// Check for reference to deleted cloud provider instances by
// all registered Kubernetes node names
// Check Kubernetes registered nodes for corresponding deleted
// Cloud Provider instance
if kubeNode, kubeNodeFound := registeredNodes[instance.Id]; kubeNodeFound {
nodesRemoved = append(nodesRemoved, kubeNode)
}
Expand Down

0 comments on commit 48b6328

Please sign in to comment.