Skip to content

Commit

Permalink
Merge pull request kubernetes#7500 from k8s-infra-cherrypick-robot/ch…
Browse files Browse the repository at this point in the history
…erry-pick-7379-to-cluster-autoscaler-release-1.29

[cluster-autoscaler-release-1.29] Remove obsolete upper bound check
  • Loading branch information
k8s-ci-robot authored Nov 15, 2024
2 parents a81f78a + 999d052 commit 204a4a7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,11 @@ func (n *nodePool) IncreaseSize(delta int) error {
if delta <= 0 {
return errors.New("size increase must be positive")
}
size, err := n.manager.GetNodeGroupSize(n)
size, err := n.manager.GetNodeGroupTargetSize(n)
if err != nil {
return err
}
targetSize := size + delta
if targetSize > n.max {
return fmt.Errorf("size increase exceeds upper bound of %d", n.max)
}
return n.manager.SetNodeGroupSize(n, targetSize)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,18 @@ func (s *NodeGroupTestSuite) TestIncreaseSize_InvalidDelta() {
}

func (s *NodeGroupTestSuite) TestIncreaseSize_GetSizeError() {
s.manager.On("GetNodeGroupSize", s.nodePool).Return(0, errors.New("error")).Once()
s.Error(s.nodePool.IncreaseSize(2))
}

func (s *NodeGroupTestSuite) TestIncreaseSize_ExceedMax() {
s.manager.On("GetNodeGroupSize", s.nodePool).Return(2, nil).Once()
s.manager.On("GetNodeGroupTargetSize", s.nodePool).Return(0, errors.New("error")).Once()
s.Error(s.nodePool.IncreaseSize(2))
}

func (s *NodeGroupTestSuite) TestIncreaseSize_SetSizeError() {
s.manager.On("GetNodeGroupSize", s.nodePool).Return(2, nil).Once()
s.manager.On("GetNodeGroupTargetSize", s.nodePool).Return(2, nil).Once()
s.manager.On("SetNodeGroupSize", s.nodePool, 3).Return(errors.New("error")).Once()
s.Error(s.nodePool.IncreaseSize(1))
}

func (s *NodeGroupTestSuite) TestIncreaseSize_OK() {
s.manager.On("GetNodeGroupSize", s.nodePool).Return(2, nil).Once()
s.manager.On("GetNodeGroupTargetSize", s.nodePool).Return(2, nil).Once()
s.manager.On("SetNodeGroupSize", s.nodePool, 3).Return(nil).Once()
s.NoError(s.nodePool.IncreaseSize(1))
}
Expand Down

0 comments on commit 204a4a7

Please sign in to comment.