Skip to content
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

fix: panic in deleteNodesFromCloudProvider #6485

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions cluster-autoscaler/core/scaledown/actuation/delete_in_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package actuation

import (
"fmt"
"reflect"
"sync"
"time"

Expand Down Expand Up @@ -71,7 +72,7 @@ func NewNodeDeletionBatcher(ctx *context.AutoscalingContext, scaleStateNotifier
func (d *NodeDeletionBatcher) AddNodes(nodes []*apiv1.Node, nodeGroup cloudprovider.NodeGroup, drain bool) {
// If delete interval is 0, than instantly start node deletion.
if d.deleteInterval == 0 {
go d.deleteNodesAndRegisterStatus(nodes, drain)
go d.deleteNodesAndRegisterStatus(nodes, nodeGroup.Id(), drain)
return
}
first := d.addNodesToBucket(nodes, nodeGroup, drain)
Expand All @@ -84,12 +85,12 @@ func (d *NodeDeletionBatcher) AddNodes(nodes []*apiv1.Node, nodeGroup cloudprovi
}
}

func (d *NodeDeletionBatcher) deleteNodesAndRegisterStatus(nodes []*apiv1.Node, drain bool) {
func (d *NodeDeletionBatcher) deleteNodesAndRegisterStatus(nodes []*apiv1.Node, nodeGroupId string, drain bool) {
nodeGroup, err := deleteNodesFromCloudProvider(d.ctx, d.scaleStateNotifier, nodes)
for _, node := range nodes {
if err != nil {
result := status.NodeDeleteResult{ResultType: status.NodeDeleteErrorFailedToDelete, Err: err}
CleanUpAndRecordFailedScaleDownEvent(d.ctx, node, nodeGroup.Id(), drain, d.nodeDeletionTracker, "", result)
CleanUpAndRecordFailedScaleDownEvent(d.ctx, node, nodeGroupId, drain, d.nodeDeletionTracker, "", result)
} else {
RegisterAndRecordSuccessfulScaleDownEvent(d.ctx, d.scaleStateNotifier, node, nodeGroup, drain, d.nodeDeletionTracker)
}
Expand Down Expand Up @@ -150,6 +151,9 @@ func deleteNodesFromCloudProvider(ctx *context.AutoscalingContext, scaleStateNot
if err != nil {
return nodeGroup, errors.NewAutoscalerError(errors.CloudProviderError, "failed to find node group for %s: %v", nodes[0].Name, err)
}
if nodeGroup == nil || reflect.ValueOf(nodeGroup).IsNil() {
return nil, errors.NewAutoscalerError(errors.InternalError, "picked node that doesn't belong to a node group: %s", nodes[0].Name)
}
if err := nodeGroup.DeleteNodes(nodes); err != nil {
scaleStateNotifier.RegisterFailedScaleDown(nodeGroup,
string(errors.CloudProviderError),
Expand Down
Loading