Skip to content

Commit

Permalink
Round up MaxUnavailable to 1 node instead of 0
Browse files Browse the repository at this point in the history
When MaxUnavailable is configured as percent and cluster is too
small we need to roundup MaxUnavailable count to 1 instead of 0
to get draining working.

Signed-off-by: Ivan Kolodiazhnyi <ikolodiazhny@nvidia.com>
  • Loading branch information
e0ne committed Jul 5, 2024
1 parent 2fed72e commit 262a805
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions api/v1/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -921,5 +921,10 @@ func (s *SriovNetworkPoolConfig) MaxUnavailable(numOfNodes int) (int, error) {
return 0, fmt.Errorf("negative number is not allowed")
}

if maxunavail == 0 {
// Round up MaxUnavailable to 1 node
return 1, nil
}

return maxunavail, nil
}
6 changes: 3 additions & 3 deletions api/v1/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1021,11 +1021,11 @@ func TestSriovNetworkPoolConfig_MaxUnavailable(t *testing.T) {
expectedErr: false,
},
{
tname: "zero",
tname: "small cluster",
maxUn: intstrutil.FromString("30%"),
maxUnNil: false,
numOfNodes: 1,
expectedNum: 0,
numOfNodes: 2,
expectedNum: 1,
expectedErr: false,
},
}
Expand Down

0 comments on commit 262a805

Please sign in to comment.