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

Don't break scale up with priority expander config #5246

Merged
merged 1 commit into from
Oct 11, 2022
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
2 changes: 1 addition & 1 deletion cluster-autoscaler/expander/priority/priority.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (p *priority) BestOptions(expansionOptions []expander.Option, nodeInfo map[

priorities, cm, err := p.reloadConfigMap()
if err != nil {
return nil
return expansionOptions
}

maxPrio := -1
Expand Down
20 changes: 10 additions & 10 deletions cluster-autoscaler/expander/priority/priority_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ var (
}
)

func getFilterInstance(t *testing.T, config string) (expander.Filter, *record.FakeRecorder, *apiv1.ConfigMap, error) {
func getFilterInstance(t *testing.T, config string) (expander.Filter, *record.FakeRecorder, *apiv1.ConfigMap) {
cm := &apiv1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Namespace: testNamespace,
Expand All @@ -101,41 +101,41 @@ func getFilterInstance(t *testing.T, config string) (expander.Filter, *record.Fa
assert.Nil(t, err)
r := record.NewFakeRecorder(100)
s := NewFilter(lister.ConfigMaps(testNamespace), r)
return s, r, cm, err
return s, r, cm
}

func TestPriorityExpanderCorrecltyFiltersSingleMatchingOptionOutOfOne(t *testing.T) {
s, _, _, _ := getFilterInstance(t, config)
s, _, _ := getFilterInstance(t, config)
ret := s.BestOptions([]expander.Option{eoT2Large}, nil)
assert.Equal(t, ret, []expander.Option{eoT2Large})
}

func TestPriorityExpanderCorrecltyFiltersSingleMatchingOptionOutOfMany(t *testing.T) {
s, _, _, _ := getFilterInstance(t, config)
s, _, _ := getFilterInstance(t, config)
ret := s.BestOptions([]expander.Option{eoT2Large, eoM44XLarge}, nil)
assert.Equal(t, ret, []expander.Option{eoM44XLarge})
}

func TestPriorityExpanderFiltersToHigherPriorityMatch(t *testing.T) {
s, _, _, _ := getFilterInstance(t, wildcardMatchConfig)
s, _, _ := getFilterInstance(t, wildcardMatchConfig)
ret := s.BestOptions([]expander.Option{eoT2Large, eoT2Micro}, nil)
assert.Equal(t, ret, []expander.Option{eoT2Large})
}

func TestPriorityExpanderCorrecltyFiltersTwoMatchingOptionsOutOfMany(t *testing.T) {
s, _, _, _ := getFilterInstance(t, config)
s, _, _ := getFilterInstance(t, config)
ret := s.BestOptions([]expander.Option{eoT2Large, eoT3Large, eoT2Micro}, nil)
assert.Equal(t, ret, []expander.Option{eoT2Large, eoT3Large})
}

func TestPriorityExpanderCorrecltyFallsBackToAllWhenNoMatches(t *testing.T) {
s, _, _, _ := getFilterInstance(t, config)
s, _, _ := getFilterInstance(t, config)
ret := s.BestOptions([]expander.Option{eoT2Large, eoT3Large}, nil)
assert.Equal(t, ret, []expander.Option{eoT2Large, eoT3Large})
}

func TestPriorityExpanderCorrecltyHandlesConfigUpdate(t *testing.T) {
s, r, cm, _ := getFilterInstance(t, oneEntryConfig)
s, r, cm := getFilterInstance(t, oneEntryConfig)
ret := s.BestOptions([]expander.Option{eoT2Large, eoT3Large, eoM44XLarge}, nil)
assert.Equal(t, ret, []expander.Option{eoT2Large})

Expand All @@ -154,7 +154,7 @@ func TestPriorityExpanderCorrecltyHandlesConfigUpdate(t *testing.T) {
}

func TestPriorityExpanderCorrecltySkipsBadChangeConfig(t *testing.T) {
s, r, cm, _ := getFilterInstance(t, oneEntryConfig)
s, r, cm := getFilterInstance(t, oneEntryConfig)
priority := s.(*priority)
assert.Equal(t, 0, priority.okConfigUpdates)

Expand All @@ -165,5 +165,5 @@ func TestPriorityExpanderCorrecltySkipsBadChangeConfig(t *testing.T) {

event := <-r.Events
assert.EqualValues(t, configWarnConfigMapEmpty, event)
assert.Empty(t, ret)
assert.Equal(t, ret, []expander.Option{eoT2Large, eoT3Large, eoM44XLarge})
}