Skip to content

Commit

Permalink
return error when nodesToDeleteCountByGroup > node count in group
Browse files Browse the repository at this point in the history
  • Loading branch information
nvthongswansea committed Sep 10, 2024
1 parent a5faf72 commit 3debed0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cluster-autoscaler/core/scaledown/actuation/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ func (a *Actuator) StartDeletionForGridscaleProvider(empty, drain, all []*apiv1.
var nodesToDeleteByGroup []*apiv1.Node
nodesToDeleteCountByGroup := len(emptyToDeleteByGroup) + len(drainToDeleteByGroup)
if nodesToDeleteCountByGroup > 0 {
if nodesToDeleteCountByGroup > len(copiedAllByGroup) {
return status.ScaleDownError, nil, errors.NewAutoscalerError(
errors.InternalError,
fmt.Sprintf("cannot delete nodes because the number of nodes to be deleted is greater than the total node count in the node group %s.", nodeGroupID),
)
}
nodesToDeleteByGroup = copiedAllByGroup[len(copiedAllByGroup)-nodesToDeleteCountByGroup:]
}
klog.V(4).Info("[**]New empty nodes to delete: ", len(nodesToDeleteByGroup))
Expand Down

0 comments on commit 3debed0

Please sign in to comment.