Merge pull request #3308 from bruecktech/fix-fallback
Fix priority expander falling back to random although higher priority matches
This commit is contained in:
parent
bc7b29e346
commit
51379c2794
|
|
@ -148,7 +148,6 @@ func (p *priority) BestOption(expansionOptions []expander.Option, nodeInfo map[s
|
||||||
}
|
}
|
||||||
best = append(best, option)
|
best = append(best, option)
|
||||||
found = true
|
found = true
|
||||||
break
|
|
||||||
}
|
}
|
||||||
if !found {
|
if !found {
|
||||||
msg := fmt.Sprintf("Priority expander: node group %s not found in priority expander configuration. "+
|
msg := fmt.Sprintf("Priority expander: node group %s not found in priority expander configuration. "+
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,13 @@ var (
|
||||||
10:
|
10:
|
||||||
- ".*t\\.large.*"
|
- ".*t\\.large.*"
|
||||||
`
|
`
|
||||||
|
wildcardMatchConfig = `
|
||||||
|
5:
|
||||||
|
- ".*"
|
||||||
|
10:
|
||||||
|
- ".t2\\.large.*"
|
||||||
|
`
|
||||||
|
|
||||||
eoT2Micro = expander.Option{
|
eoT2Micro = expander.Option{
|
||||||
Debug: "t2.micro",
|
Debug: "t2.micro",
|
||||||
NodeGroup: test.NewTestNodeGroup("my-asg.t2.micro", 10, 1, 1, true, false, "t2.micro", nil, nil),
|
NodeGroup: test.NewTestNodeGroup("my-asg.t2.micro", 10, 1, 1, true, false, "t2.micro", nil, nil),
|
||||||
|
|
@ -109,6 +116,14 @@ func TestPriorityExpanderCorrecltySelectsSingleMatchingOptionOutOfMany(t *testin
|
||||||
assert.Equal(t, *ret, eoM44XLarge)
|
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) {
|
func TestPriorityExpanderCorrecltySelectsOneOfTwoMatchingOptionsOutOfMany(t *testing.T) {
|
||||||
s, _, _, _ := getStrategyInstance(t, config)
|
s, _, _, _ := getStrategyInstance(t, config)
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue