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 38ee3be
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 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
}
7 changes: 7 additions & 0 deletions api/v1/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,13 @@ func TestSriovNetworkPoolConfig_MaxUnavailable(t *testing.T) {
expectedNum: 0,
expectedErr: true,
},
{
tname: "small cluster",
maxUn: intstrutil.FromString("10%"),
numOfNodes: 2,
expectedNum: 1,
expectedErr: false,
},
{
tname: "parallel",
maxUn: intstrutil.FromInt32(-1),
Expand Down

0 comments on commit 38ee3be

Please sign in to comment.