Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions pkg/controller/update_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,8 @@ func (c *M3DBController) findPodsAndInstancesToRemove(
if len(pods) == 0 {
return nil, nil, errEmptyPodList
}
if desiredInstanceCount < 0 {
msg := fmt.Sprintf("desired instance count is negative: %d", desiredInstanceCount)
if desiredInstanceCount <= 0 {
msg := fmt.Sprintf("desired instance count should be positive, but is: %d", desiredInstanceCount)
return nil, nil, pkgerrors.New(msg)
}

Expand Down
12 changes: 4 additions & 8 deletions pkg/controller/update_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,20 +715,16 @@ func TestShrinkPlacementForSet(t *testing.T) {
expectedRemovedIds: []string{`{"name":"cluster-zones-rep0-1","uid":"1"}`},
},
{
name: "remove more pods than exists",
name: "negative desired instance count",
desiredInstanceCount: -42,
placementInstanceCount: instanceCountPerGroup,
expectedErr: "desired instance count is negative: -42",
expectedErr: "desired instance count should be positive, but is: -42",
},
{
name: "remove all pods",
name: "0 desired instances",
desiredInstanceCount: 0,
placementInstanceCount: instanceCountPerGroup,
expectedRemovedIds: []string{
`{"name":"cluster-zones-rep0-2","uid":"2"}`,
`{"name":"cluster-zones-rep0-1","uid":"1"}`,
`{"name":"cluster-zones-rep0-0","uid":"0"}`,
},
expectedErr: "desired instance count should be positive, but is: 0",
},
{
name: "prevent scale down",
Expand Down