Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix priority expander falling back to random although higher priority matches #3308

Merged
merged 1 commit into from
Aug 5, 2020
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
1 change: 0 additions & 1 deletion cluster-autoscaler/expander/priority/priority.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ func (p *priority) BestOption(expansionOptions []expander.Option, nodeInfo map[s
}
best = append(best, option)
found = true
break
}
if !found {
msg := fmt.Sprintf("Priority expander: node group %s not found in priority expander configuration. "+
Expand Down
15 changes: 15 additions & 0 deletions cluster-autoscaler/expander/priority/priority_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ var (
10:
- ".*t\\.large.*"
`
wildcardMatchConfig = `
5:
- ".*"
10:
- ".t2\\.large.*"
`

eoT2Micro = expander.Option{
Debug: "t2.micro",
NodeGroup: test.NewTestNodeGroup("my-asg.t2.micro", 10, 1, 1, true, false, "t2.micro", nil, nil),
Expand Down Expand Up @@ -109,6 +116,14 @@ func TestPriorityExpanderCorrecltySelectsSingleMatchingOptionOutOfMany(t *testin
assert.Equal(t, *ret, eoM44XLarge)
}

func TestPriorityExpanderDoesNotFallBackToRandomWhenHigherPriorityMatches(t *testing.T) {
s, _, _, _ := getStrategyInstance(t, wildcardMatchConfig)
for i := 0; i < 10; i++ {
ret := s.BestOption([]expander.Option{eoT2Large, eoT2Micro}, nil)
assert.Equal(t, *ret, eoT2Large)
}
}

func TestPriorityExpanderCorrecltySelectsOneOfTwoMatchingOptionsOutOfMany(t *testing.T) {
s, _, _, _ := getStrategyInstance(t, config)
for i := 0; i < 10; i++ {
Expand Down