-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Do not remove healthy nodes from partially failing zero-or-max-scaling node groups #8291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
adamoldak
wants to merge
1
commit into
kubernetes:master
Choose a base branch
from
adamoldak:zero_or_max_scaling_scaleup_errors
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+265
−80
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -801,29 +801,31 @@ func (a *StaticAutoscaler) removeOldUnregisteredNodes(allUnregisteredNodes []clu | |
continue | ||
} | ||
|
||
if a.ForceDeleteLongUnregisteredNodes { | ||
err = nodeGroup.ForceDeleteNodes(nodesToDelete) | ||
if err == cloudprovider.ErrNotImplemented { | ||
if len(nodesToDelete) > 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can return on |
||
if a.ForceDeleteLongUnregisteredNodes { | ||
err = nodeGroup.ForceDeleteNodes(nodesToDelete) | ||
if err == cloudprovider.ErrNotImplemented { | ||
err = nodeGroup.DeleteNodes(nodesToDelete) | ||
} | ||
} else { | ||
err = nodeGroup.DeleteNodes(nodesToDelete) | ||
} | ||
} else { | ||
err = nodeGroup.DeleteNodes(nodesToDelete) | ||
} | ||
csr.InvalidateNodeInstancesCacheEntry(nodeGroup) | ||
if err != nil { | ||
klog.Warningf("Failed to remove %v unregistered nodes from node group %s: %v", len(nodesToDelete), nodeGroupId, err) | ||
csr.InvalidateNodeInstancesCacheEntry(nodeGroup) | ||
if err != nil { | ||
klog.Warningf("Failed to remove %v unregistered nodes from node group %s: %v", len(nodesToDelete), nodeGroupId, err) | ||
for _, node := range nodesToDelete { | ||
logRecorder.Eventf(apiv1.EventTypeWarning, "DeleteUnregisteredFailed", | ||
"Failed to remove node %s: %v", node.Name, err) | ||
} | ||
return removedAny, err | ||
} | ||
for _, node := range nodesToDelete { | ||
logRecorder.Eventf(apiv1.EventTypeWarning, "DeleteUnregisteredFailed", | ||
"Failed to remove node %s: %v", node.Name, err) | ||
logRecorder.Eventf(apiv1.EventTypeNormal, "DeleteUnregistered", | ||
"Removed unregistered node %v", node.Name) | ||
} | ||
return removedAny, err | ||
} | ||
for _, node := range nodesToDelete { | ||
logRecorder.Eventf(apiv1.EventTypeNormal, "DeleteUnregistered", | ||
"Removed unregistered node %v", node.Name) | ||
metrics.RegisterOldUnregisteredNodesRemoved(len(nodesToDelete)) | ||
removedAny = true | ||
} | ||
metrics.RegisterOldUnregisteredNodesRemoved(len(nodesToDelete)) | ||
removedAny = true | ||
} | ||
return removedAny, nil | ||
} | ||
|
@@ -880,12 +882,14 @@ func (a *StaticAutoscaler) deleteCreatedNodesWithErrors() { | |
if nodeGroup == nil { | ||
err = fmt.Errorf("node group %s not found", nodeGroupId) | ||
} else if nodesToDelete, err = overrideNodesToDeleteForZeroOrMax(a.NodeGroupDefaults, nodeGroup, nodesToDelete); err == nil { | ||
err = nodeGroup.DeleteNodes(nodesToDelete) | ||
if len(nodesToDelete) > 0 { | ||
err = nodeGroup.DeleteNodes(nodesToDelete) | ||
} | ||
} | ||
|
||
if err != nil { | ||
klog.Warningf("Error while trying to delete nodes from %v: %v", nodeGroupId, err) | ||
} else { | ||
} else if len(nodesToDelete) > 0 { | ||
deletedAny = true | ||
a.clusterStateRegistry.InvalidateNodeInstancesCacheEntry(nodeGroup) | ||
} | ||
|
@@ -898,21 +902,29 @@ func (a *StaticAutoscaler) deleteCreatedNodesWithErrors() { | |
} | ||
|
||
// overrideNodesToDeleteForZeroOrMax returns a list of nodes to delete, taking into account that | ||
// node deletion for a "ZeroOrMaxNodeScaling" node group is atomic and should delete all nodes. | ||
// node deletion for a "ZeroOrMaxNodeScaling" should either keep or remove all the nodes. | ||
// For a non-"ZeroOrMaxNodeScaling" node group it returns the unchanged list of nodes to delete. | ||
func overrideNodesToDeleteForZeroOrMax(defaults config.NodeGroupAutoscalingOptions, nodeGroup cloudprovider.NodeGroup, nodesToDelete []*apiv1.Node) ([]*apiv1.Node, error) { | ||
opts, err := nodeGroup.GetOptions(defaults) | ||
if err != nil && err != cloudprovider.ErrNotImplemented { | ||
return []*apiv1.Node{}, fmt.Errorf("Failed to get node group options for %s: %s", nodeGroup.Id(), err) | ||
} | ||
// If a scale-up of "ZeroOrMaxNodeScaling" node group failed, the cleanup | ||
// should stick to the all-or-nothing principle. Deleting all nodes. | ||
// node deletion for a "ZeroOrMaxNodeScaling" node group is atomic and should delete all nodes or none. | ||
if opts != nil && opts.ZeroOrMaxNodeScaling { | ||
instances, err := nodeGroup.Nodes() | ||
if err != nil { | ||
return []*apiv1.Node{}, fmt.Errorf("Failed to fill in nodes to delete from group %s based on ZeroOrMaxNodeScaling option: %s", nodeGroup.Id(), err) | ||
} | ||
return instancesToFakeNodes(instances), nil | ||
|
||
// Remove all nodes in case when either: | ||
// 1. All nodes are failing | ||
// 2. KeepPartiallyFailedZeroOrMaxScalingNodeGroups is false which means we want to atomically remove partially failed node groups | ||
if len(instances) == len(nodesToDelete) || !opts.KeepPartiallyFailedZeroOrMaxScalingNodeGroups { | ||
// Remove all nodes | ||
return instancesToFakeNodes(instances), nil | ||
} | ||
return []*apiv1.Node{}, nil | ||
} | ||
// No override needed. | ||
return nodesToDelete, nil | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
DisableAtomicZeroOrMaxNodeScaling
? We are effectively removing the atomic part of the logic.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not fully. We still scale down atomically, regardless if there were failed nodes during scale-up or not. So maybe
AllowNonAtomicScaleUpToMax
?