From e291b71ddf706582069ae61a01a0ee2285af97ad Mon Sep 17 00:00:00 2001 From: Kushagra Date: Tue, 27 Jun 2023 10:41:08 +0000 Subject: [PATCH 1/2] Sort nodegroups in order of their ID --- cluster-autoscaler/cloudprovider/test/test_cloud_provider.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cluster-autoscaler/cloudprovider/test/test_cloud_provider.go b/cluster-autoscaler/cloudprovider/test/test_cloud_provider.go index 274933428a8f..3f6eed01108d 100644 --- a/cluster-autoscaler/cloudprovider/test/test_cloud_provider.go +++ b/cluster-autoscaler/cloudprovider/test/test_cloud_provider.go @@ -18,6 +18,7 @@ package test import ( "fmt" + "sort" "sync" apiv1 "k8s.io/api/core/v1" @@ -136,6 +137,10 @@ func (tcp *TestCloudProvider) NodeGroups() []cloudprovider.NodeGroup { for _, group := range tcp.groups { result = append(result, group) } + // Sort the nodegroups in order of Id. + sort.Slice(result, func(i, j int) bool { + return result[i].Id() < result[j].Id() + }) return result } From 072317f001ecdada8b2aa7f9b9fc7fb5a207eeb5 Mon Sep 17 00:00:00 2001 From: Kushagra Date: Tue, 27 Jun 2023 13:31:25 +0000 Subject: [PATCH 2/2] address comments --- cluster-autoscaler/cloudprovider/test/test_cloud_provider.go | 5 ----- .../core/scaleup/orchestrator/orchestrator_test.go | 1 - 2 files changed, 6 deletions(-) diff --git a/cluster-autoscaler/cloudprovider/test/test_cloud_provider.go b/cluster-autoscaler/cloudprovider/test/test_cloud_provider.go index 3f6eed01108d..274933428a8f 100644 --- a/cluster-autoscaler/cloudprovider/test/test_cloud_provider.go +++ b/cluster-autoscaler/cloudprovider/test/test_cloud_provider.go @@ -18,7 +18,6 @@ package test import ( "fmt" - "sort" "sync" apiv1 "k8s.io/api/core/v1" @@ -137,10 +136,6 @@ func (tcp *TestCloudProvider) NodeGroups() []cloudprovider.NodeGroup { for _, group := range tcp.groups { result = append(result, group) } - // Sort the nodegroups in order of Id. - sort.Slice(result, func(i, j int) bool { - return result[i].Id() < result[j].Id() - }) return result } diff --git a/cluster-autoscaler/core/scaleup/orchestrator/orchestrator_test.go b/cluster-autoscaler/core/scaleup/orchestrator/orchestrator_test.go index c96c1485e776..1ca6d54e0708 100644 --- a/cluster-autoscaler/core/scaleup/orchestrator/orchestrator_test.go +++ b/cluster-autoscaler/core/scaleup/orchestrator/orchestrator_test.go @@ -860,7 +860,6 @@ func TestBinpackingLimiter(t *testing.T) { expansionOptions := expander.LastInputOptions() // Only 1 expansion option should be there. Without BinpackingLimiter there will be 2. assert.True(t, len(expansionOptions) == 1) - assert.Equal(t, expansionOptions, []GroupSizeChange{{GroupName: "ng1", SizeChange: 1}}) } func TestScaleUpNoHelp(t *testing.T) {