From 0e4a077c58f9c6469afcb4fc03dd9e39ca513193 Mon Sep 17 00:00:00 2001 From: Kubernetes Prow Robot Date: Wed, 5 Aug 2020 04:48:28 -0700 Subject: [PATCH 1/2] Merge pull request #3308 from bruecktech/fix-fallback Fix priority expander falling back to random although higher priority matches --- cluster-autoscaler/expander/priority/priority.go | 1 - .../expander/priority/priority_test.go | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cluster-autoscaler/expander/priority/priority.go b/cluster-autoscaler/expander/priority/priority.go index 57abd32f6e42..66b1f410534a 100644 --- a/cluster-autoscaler/expander/priority/priority.go +++ b/cluster-autoscaler/expander/priority/priority.go @@ -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. "+ diff --git a/cluster-autoscaler/expander/priority/priority_test.go b/cluster-autoscaler/expander/priority/priority_test.go index 592d2e26e323..1796ef7a422d 100644 --- a/cluster-autoscaler/expander/priority/priority_test.go +++ b/cluster-autoscaler/expander/priority/priority_test.go @@ -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), @@ -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++ { From 6efff86d159c2b3c8d33ffacd74b7c8a3ca5b73d Mon Sep 17 00:00:00 2001 From: nitrag Date: Thu, 8 Oct 2020 16:54:59 -0400 Subject: [PATCH 2/2] Revert version --- cluster-autoscaler/version/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster-autoscaler/version/version.go b/cluster-autoscaler/version/version.go index a6b3ebeb6f2e..592433d44301 100644 --- a/cluster-autoscaler/version/version.go +++ b/cluster-autoscaler/version/version.go @@ -17,4 +17,4 @@ limitations under the License. package version // ClusterAutoscalerVersion contains version of CA. -const ClusterAutoscalerVersion = "1.19.0" +const ClusterAutoscalerVersion = "1.19.0-beta.1"