From d8bfca592f377b0c79d31a52ddcdd55fab312763 Mon Sep 17 00:00:00 2001 From: haoqing0110 Date: Mon, 27 Sep 2021 06:14:24 +0000 Subject: [PATCH] remove prioritizor ResourceRatioCPU and ResourceRatioMemory related code Signed-off-by: haoqing0110 --- deploy/hub/placements.crd.yaml | 4 +- go.mod | 2 +- go.sum | 4 +- pkg/controllers/scheduling/schedule.go | 2 - pkg/controllers/scheduling/schedule_test.go | 106 ++---------------- pkg/plugins/resource/resource.go | 35 +----- pkg/plugins/resource/resource_test.go | 97 ---------------- test/integration/placement_test.go | 66 +++-------- vendor/modules.txt | 2 +- ...-cluster-management.io_placements.crd.yaml | 4 +- .../api/cluster/v1alpha1/types.go | 3 +- .../zz_generated.swagger_doc_generated.go | 2 +- 12 files changed, 35 insertions(+), 292 deletions(-) diff --git a/deploy/hub/placements.crd.yaml b/deploy/hub/placements.crd.yaml index f119d84c2..abeb63876 100644 --- a/deploy/hub/placements.crd.yaml +++ b/deploy/hub/placements.crd.yaml @@ -212,9 +212,7 @@ spec: description: 'Name is the name of a prioritizer. Below are the valid names: 1) Balance: balance the decisions among the clusters. 2) Steady: ensure the existing decision - is stabilized. 3) ResourceRatioCPU & ResourceRatioMemory: - sort clusters based on the allocatable to capacity ratio. - 4) ResourceAllocatableCPU & ResourceAllocatableMemory: + is stabilized. 3) ResourceAllocatableCPU & ResourceAllocatableMemory: sort clusters based on the allocatable.' type: string weight: diff --git a/go.mod b/go.mod index ea94f85fb..b964c21d1 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,6 @@ require ( k8s.io/client-go v0.21.1 k8s.io/component-base v0.21.0 k8s.io/klog/v2 v2.8.0 - open-cluster-management.io/api v0.0.0-20210916013819-2e58cdb938f9 + open-cluster-management.io/api v0.0.0-20210927063308-2c6896161c48 sigs.k8s.io/controller-runtime v0.8.3 ) diff --git a/go.sum b/go.sum index 1512dcefe..85f0d700b 100644 --- a/go.sum +++ b/go.sum @@ -959,8 +959,8 @@ modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= modernc.org/strutil v1.0.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs= modernc.org/xc v1.0.0/go.mod h1:mRNCo0bvLjGhHO9WsyuKVU4q0ceiDDDoEeWDJHrNx8I= -open-cluster-management.io/api v0.0.0-20210916013819-2e58cdb938f9 h1:ySrjJFbSuPbHEN0OvzTeQO8Bt93rjgvbce7lo2cQeZY= -open-cluster-management.io/api v0.0.0-20210916013819-2e58cdb938f9/go.mod h1:9qiA5h/8kvPQnJEOlAPHVjRO9a1jCmDhGzvgMBvXEaE= +open-cluster-management.io/api v0.0.0-20210927063308-2c6896161c48 h1:Kkfl2LtG41l3e729ROSzIV6Kvevty1sVY2sFbGCXd20= +open-cluster-management.io/api v0.0.0-20210927063308-2c6896161c48/go.mod h1:9qiA5h/8kvPQnJEOlAPHVjRO9a1jCmDhGzvgMBvXEaE= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/pkg/controllers/scheduling/schedule.go b/pkg/controllers/scheduling/schedule.go index e66daa219..669c77554 100644 --- a/pkg/controllers/scheduling/schedule.go +++ b/pkg/controllers/scheduling/schedule.go @@ -123,8 +123,6 @@ func NewPluginScheduler(handle plugins.Handle) *pluginScheduler { steady.New(handle), resource.NewResourcePrioritizerBuilder(handle).WithPrioritizerName("ResourceAllocatableCPU").Build(), resource.NewResourcePrioritizerBuilder(handle).WithPrioritizerName("ResourceAllocatableMemory").Build(), - resource.NewResourcePrioritizerBuilder(handle).WithPrioritizerName("ResourceRatioCPU").Build(), - resource.NewResourcePrioritizerBuilder(handle).WithPrioritizerName("ResourceRatioMemory").Build(), }, prioritizerWeights: defaultPrioritizerConfig, } diff --git a/pkg/controllers/scheduling/schedule_test.go b/pkg/controllers/scheduling/schedule_test.go index fd29dac92..a5f6a769c 100644 --- a/pkg/controllers/scheduling/schedule_test.go +++ b/pkg/controllers/scheduling/schedule_test.go @@ -69,16 +69,6 @@ func TestSchedule(t *testing.T) { Weight: 0, Scores: nil, }, - { - Name: "ResourceRatioCPU", - Weight: 0, - Scores: nil, - }, - { - Name: "ResourceRatioMemory", - Weight: 0, - Scores: nil, - }, }, clusters: []*clusterapiv1.ManagedCluster{ testinghelpers.NewManagedCluster("cluster1").WithLabel(clusterSetLabel, clusterSetName).Build(), @@ -126,16 +116,6 @@ func TestSchedule(t *testing.T) { Weight: 0, Scores: nil, }, - { - Name: "ResourceRatioCPU", - Weight: 0, - Scores: nil, - }, - { - Name: "ResourceRatioMemory", - Weight: 0, - Scores: nil, - }, }, expectedUnScheduled: 2, }, @@ -190,16 +170,6 @@ func TestSchedule(t *testing.T) { Weight: 0, Scores: nil, }, - { - Name: "ResourceRatioCPU", - Weight: 0, - Scores: nil, - }, - { - Name: "ResourceRatioMemory", - Weight: 0, - Scores: nil, - }, }, expectedUnScheduled: 0, }, @@ -241,16 +211,6 @@ func TestSchedule(t *testing.T) { Weight: 0, Scores: nil, }, - { - Name: "ResourceRatioCPU", - Weight: 0, - Scores: nil, - }, - { - Name: "ResourceRatioMemory", - Weight: 0, - Scores: nil, - }, }, clusters: []*clusterapiv1.ManagedCluster{ testinghelpers.NewManagedCluster("cluster1").WithLabel(clusterSetLabel, clusterSetName).Build(), @@ -259,15 +219,15 @@ func TestSchedule(t *testing.T) { }, { name: "placement with additive Prioritizer Policy", - placement: testinghelpers.NewPlacement(placementNamespace, placementName).WithNOC(2).WithPrioritizerPolicy("Additive").WithPrioritizerConfig("Balance", 3).WithPrioritizerConfig("ResourceRatioCPU", 1).Build(), + placement: testinghelpers.NewPlacement(placementNamespace, placementName).WithNOC(2).WithPrioritizerPolicy("Additive").WithPrioritizerConfig("Balance", 3).WithPrioritizerConfig("ResourceAllocatableMemory", 1).Build(), initObjs: []runtime.Object{ testinghelpers.NewClusterSet(clusterSetName), testinghelpers.NewClusterSetBinding(placementNamespace, clusterSetName), }, clusters: []*clusterapiv1.ManagedCluster{ - testinghelpers.NewManagedCluster("cluster1").WithLabel(clusterSetLabel, clusterSetName).WithResource(clusterapiv1.ResourceCPU, "10", "10").Build(), - testinghelpers.NewManagedCluster("cluster2").WithLabel(clusterSetLabel, clusterSetName).WithResource(clusterapiv1.ResourceCPU, "5", "10").Build(), - testinghelpers.NewManagedCluster("cluster3").WithLabel(clusterSetLabel, clusterSetName).WithResource(clusterapiv1.ResourceCPU, "0", "10").Build(), + testinghelpers.NewManagedCluster("cluster1").WithLabel(clusterSetLabel, clusterSetName).WithResource(clusterapiv1.ResourceMemory, "100", "100").Build(), + testinghelpers.NewManagedCluster("cluster2").WithLabel(clusterSetLabel, clusterSetName).WithResource(clusterapiv1.ResourceMemory, "50", "100").Build(), + testinghelpers.NewManagedCluster("cluster3").WithLabel(clusterSetLabel, clusterSetName).WithResource(clusterapiv1.ResourceMemory, "0", "100").Build(), }, decisions: []runtime.Object{}, expectedDecisions: []clusterapiv1alpha1.ClusterDecision{ @@ -298,33 +258,23 @@ func TestSchedule(t *testing.T) { }, { Name: "ResourceAllocatableMemory", - Weight: 0, - Scores: nil, - }, - { - Name: "ResourceRatioCPU", Weight: 1, Scores: PrioritizerScore{"cluster1": 100, "cluster2": 0, "cluster3": -100}, }, - { - Name: "ResourceRatioMemory", - Weight: 0, - Scores: nil, - }, }, expectedUnScheduled: 0, }, { name: "placement with exact Prioritizer Policy", - placement: testinghelpers.NewPlacement(placementNamespace, placementName).WithNOC(2).WithPrioritizerPolicy("Exact").WithPrioritizerConfig("Balance", 3).WithPrioritizerConfig("ResourceRatioCPU", 1).Build(), + placement: testinghelpers.NewPlacement(placementNamespace, placementName).WithNOC(2).WithPrioritizerPolicy("Exact").WithPrioritizerConfig("Balance", 3).WithPrioritizerConfig("ResourceAllocatableMemory", 1).Build(), initObjs: []runtime.Object{ testinghelpers.NewClusterSet(clusterSetName), testinghelpers.NewClusterSetBinding(placementNamespace, clusterSetName), }, clusters: []*clusterapiv1.ManagedCluster{ - testinghelpers.NewManagedCluster("cluster1").WithLabel(clusterSetLabel, clusterSetName).WithResource(clusterapiv1.ResourceCPU, "10", "10").Build(), - testinghelpers.NewManagedCluster("cluster2").WithLabel(clusterSetLabel, clusterSetName).WithResource(clusterapiv1.ResourceCPU, "5", "10").Build(), - testinghelpers.NewManagedCluster("cluster3").WithLabel(clusterSetLabel, clusterSetName).WithResource(clusterapiv1.ResourceCPU, "0", "10").Build(), + testinghelpers.NewManagedCluster("cluster1").WithLabel(clusterSetLabel, clusterSetName).WithResource(clusterapiv1.ResourceMemory, "100", "100").Build(), + testinghelpers.NewManagedCluster("cluster2").WithLabel(clusterSetLabel, clusterSetName).WithResource(clusterapiv1.ResourceMemory, "50", "100").Build(), + testinghelpers.NewManagedCluster("cluster3").WithLabel(clusterSetLabel, clusterSetName).WithResource(clusterapiv1.ResourceMemory, "0", "100").Build(), }, decisions: []runtime.Object{}, expectedDecisions: []clusterapiv1alpha1.ClusterDecision{ @@ -355,19 +305,9 @@ func TestSchedule(t *testing.T) { }, { Name: "ResourceAllocatableMemory", - Weight: 0, - Scores: nil, - }, - { - Name: "ResourceRatioCPU", Weight: 1, Scores: PrioritizerScore{"cluster1": 100, "cluster2": 0, "cluster3": -100}, }, - { - Name: "ResourceRatioMemory", - Weight: 0, - Scores: nil, - }, }, expectedUnScheduled: 0, }, @@ -421,16 +361,6 @@ func TestSchedule(t *testing.T) { Weight: 0, Scores: nil, }, - { - Name: "ResourceRatioCPU", - Weight: 0, - Scores: nil, - }, - { - Name: "ResourceRatioMemory", - Weight: 0, - Scores: nil, - }, }, expectedUnScheduled: 2, }, @@ -482,16 +412,6 @@ func TestSchedule(t *testing.T) { Weight: 0, Scores: nil, }, - { - Name: "ResourceRatioCPU", - Weight: 0, - Scores: nil, - }, - { - Name: "ResourceRatioMemory", - Weight: 0, - Scores: nil, - }, }, expectedUnScheduled: 0, }, @@ -553,16 +473,6 @@ func TestSchedule(t *testing.T) { Weight: 0, Scores: nil, }, - { - Name: "ResourceRatioCPU", - Weight: 0, - Scores: nil, - }, - { - Name: "ResourceRatioMemory", - Weight: 0, - Scores: nil, - }, }, expectedUnScheduled: 0, }, diff --git a/pkg/plugins/resource/resource.go b/pkg/plugins/resource/resource.go index 07a24d980..15e5d65f0 100644 --- a/pkg/plugins/resource/resource.go +++ b/pkg/plugins/resource/resource.go @@ -14,10 +14,9 @@ import ( const ( placementLabel = clusterapiv1alpha1.PlacementLabel description = ` - ResourceRatio[ResourceType] and ResourceAllocatable[ResourceType] prioritizer makes the scheduling - decisions based on the resource allocatable to capacity ratio or allocatable of managed clusters. - The [ResourceType] could be CPU or Memory. - The clusters that has the most allocatable to capacity ratio or allocatable are given the highest score, + ResourceAllocatableCPU and ResourceAllocatableMemory prioritizer makes the scheduling + decisions based on the resource allocatable of managed clusters. + The clusters that has the most allocatable are given the highest score, while the least is given the lowest score. ` ) @@ -79,38 +78,12 @@ func (r *ResourcePrioritizer) Description() string { } func (r *ResourcePrioritizer) Score(ctx context.Context, placement *clusterapiv1alpha1.Placement, clusters []*clusterapiv1.ManagedCluster) (map[string]int64, error) { - switch r.algorithm { - case "Ratio": - return mostResourceRatioScores(r.resource, clusters) - case "Allocatable": + if r.algorithm == "Allocatable" { return mostResourceAllocatableScores(r.resource, clusters) } return nil, nil } -// Calculate clusters scores based on the resource allocatable to capacity ratio. -// The clusters that has the most allocatable to capacity ratio are given the highest score, while the least is given the lowest score. -// The score range is from -100 to 100. -func mostResourceRatioScores(resourceName clusterapiv1.ResourceName, clusters []*clusterapiv1.ManagedCluster) (map[string]int64, error) { - scores := map[string]int64{} - - for _, cluster := range clusters { - // get cluster resourceName's allocatable and capacity - allocatable, capacity, err := getClusterResource(cluster, resourceName) - if err != nil { - continue - } - - // score = (resource_x_allocatable / resource_x_capacity - 0.5) * 2 * 100 - if capacity != 0 { - ratio := float64(allocatable) / float64(capacity) - scores[cluster.Name] = int64((ratio - 0.5) * 2.0 * 100.0) - } - } - - return scores, nil -} - // Calculate clusters scores based on the resource allocatable. // The clusters that has the most allocatable are given the highest score, while the least is given the lowest score. // The score range is from -100 to 100. diff --git a/pkg/plugins/resource/resource_test.go b/pkg/plugins/resource/resource_test.go index aec5889c7..02b771b85 100644 --- a/pkg/plugins/resource/resource_test.go +++ b/pkg/plugins/resource/resource_test.go @@ -21,103 +21,6 @@ func TestScoreClusterWithResource(t *testing.T) { existingDecisions []runtime.Object expectedScores map[string]int64 }{ - { - name: "scores of ResourceRatioMemory", - resource: clusterapiv1.ResourceMemory, - algorithm: "Ratio", - placement: testinghelpers.NewPlacement("test", "test").Build(), - clusters: []*clusterapiv1.ManagedCluster{ - testinghelpers.NewManagedCluster("cluster1").WithResource(clusterapiv1.ResourceMemory, "20", "100").Build(), - testinghelpers.NewManagedCluster("cluster2").WithResource(clusterapiv1.ResourceMemory, "50", "100").Build(), - testinghelpers.NewManagedCluster("cluster3").WithResource(clusterapiv1.ResourceMemory, "100", "100").Build(), - }, - existingDecisions: []runtime.Object{}, - expectedScores: map[string]int64{"cluster1": -60, "cluster2": 0, "cluster3": 100}, - }, - { - name: "scores of ResourceRatioMemory with same resource value", - resource: clusterapiv1.ResourceMemory, - algorithm: "Ratio", - placement: testinghelpers.NewPlacement("test", "test").Build(), - clusters: []*clusterapiv1.ManagedCluster{ - testinghelpers.NewManagedCluster("cluster1").WithResource(clusterapiv1.ResourceMemory, "50", "100").Build(), - testinghelpers.NewManagedCluster("cluster2").WithResource(clusterapiv1.ResourceMemory, "50", "100").Build(), - testinghelpers.NewManagedCluster("cluster3").WithResource(clusterapiv1.ResourceMemory, "50", "100").Build(), - }, - expectedScores: map[string]int64{"cluster1": 0, "cluster2": 0, "cluster3": 0}, - }, - { - name: "scores of ResourceRatioMemory with zero resource value", - resource: clusterapiv1.ResourceMemory, - algorithm: "Ratio", - placement: testinghelpers.NewPlacement("test", "test").Build(), - clusters: []*clusterapiv1.ManagedCluster{ - testinghelpers.NewManagedCluster("cluster1").WithResource(clusterapiv1.ResourceMemory, "0", "100").Build(), - testinghelpers.NewManagedCluster("cluster2").WithResource(clusterapiv1.ResourceMemory, "0", "100").Build(), - testinghelpers.NewManagedCluster("cluster3").WithResource(clusterapiv1.ResourceMemory, "0", "100").Build(), - }, - expectedScores: map[string]int64{"cluster1": -100, "cluster2": -100, "cluster3": -100}, - }, - { - name: "scores of ResourceRatioMemory with no cluster resource", - resource: clusterapiv1.ResourceMemory, - algorithm: "Ratio", - placement: testinghelpers.NewPlacement("test", "test").Build(), - clusters: []*clusterapiv1.ManagedCluster{ - testinghelpers.NewManagedCluster("cluster1").Build(), - testinghelpers.NewManagedCluster("cluster2").Build(), - testinghelpers.NewManagedCluster("cluster3").Build(), - }, - expectedScores: map[string]int64{}, - }, - { - name: "scores of ResourceRatioCPU", - resource: clusterapiv1.ResourceCPU, - algorithm: "Ratio", - placement: testinghelpers.NewPlacement("test", "test").Build(), - clusters: []*clusterapiv1.ManagedCluster{ - testinghelpers.NewManagedCluster("cluster1").WithResource(clusterapiv1.ResourceCPU, "10", "10").Build(), - testinghelpers.NewManagedCluster("cluster2").WithResource(clusterapiv1.ResourceCPU, "5", "10").Build(), - testinghelpers.NewManagedCluster("cluster3").WithResource(clusterapiv1.ResourceCPU, "2", "10").Build(), - }, - expectedScores: map[string]int64{"cluster1": 100, "cluster2": 0, "cluster3": -60}, - }, - { - name: "scores of ResourceRatioCPU with same resource value", - resource: clusterapiv1.ResourceCPU, - algorithm: "Ratio", - placement: testinghelpers.NewPlacement("test", "test").Build(), - clusters: []*clusterapiv1.ManagedCluster{ - testinghelpers.NewManagedCluster("cluster1").WithResource(clusterapiv1.ResourceCPU, "5", "10").Build(), - testinghelpers.NewManagedCluster("cluster2").WithResource(clusterapiv1.ResourceCPU, "5", "10").Build(), - testinghelpers.NewManagedCluster("cluster3").WithResource(clusterapiv1.ResourceCPU, "5", "10").Build(), - }, - expectedScores: map[string]int64{"cluster1": 0, "cluster2": 0, "cluster3": 0}, - }, - { - name: "scores of ResourceRatioCPU with zero resource value", - resource: clusterapiv1.ResourceCPU, - algorithm: "Ratio", - placement: testinghelpers.NewPlacement("test", "test").Build(), - clusters: []*clusterapiv1.ManagedCluster{ - testinghelpers.NewManagedCluster("cluster1").WithResource(clusterapiv1.ResourceCPU, "0", "10").Build(), - testinghelpers.NewManagedCluster("cluster2").WithResource(clusterapiv1.ResourceCPU, "0", "10").Build(), - testinghelpers.NewManagedCluster("cluster3").WithResource(clusterapiv1.ResourceCPU, "0", "10").Build(), - }, - expectedScores: map[string]int64{"cluster1": -100, "cluster2": -100, "cluster3": -100}, - }, - { - name: "scores of ResourceRatioCPU with no cluster resource", - resource: clusterapiv1.ResourceCPU, - algorithm: "Ratio", - placement: testinghelpers.NewPlacement("test", "test").Build(), - clusters: []*clusterapiv1.ManagedCluster{ - testinghelpers.NewManagedCluster("cluster1").Build(), - testinghelpers.NewManagedCluster("cluster2").Build(), - testinghelpers.NewManagedCluster("cluster3").Build(), - }, - expectedScores: map[string]int64{}, - }, { name: "scores of ResourceAllocatableMemory", resource: clusterapiv1.ResourceMemory, diff --git a/test/integration/placement_test.go b/test/integration/placement_test.go index 8cb213d0b..37af6e173 100644 --- a/test/integration/placement_test.go +++ b/test/integration/placement_test.go @@ -480,47 +480,7 @@ var _ = ginkgo.Describe("Placement", func() { assertClusterNamesOfDecisions(placementName, []string{clusterNames[0], clusterNames[1]}) }) - ginkgo.It("Should schedule successfully based on SchedulePolicy ResourceRatioCPU and ResourceRatioCPU", func() { - // cluster settings - clusterNames := []string{ - clusterName + "-1", - clusterName + "-2", - clusterName + "-3", - } - clusterResources := make([][]string, len(clusterNames)) - clusterResources[0] = []string{"10", "10", "50", "100"} - clusterResources[1] = []string{"7", "10", "90", "100"} - clusterResources[2] = []string{"9", "10", "80", "100"} - - // placement settings - prioritizerPolicy := clusterapiv1alpha1.PrioritizerPolicy{ - Mode: clusterapiv1alpha1.PrioritizerPolicyModeExact, - Configurations: []clusterapiv1alpha1.PrioritizerConfig{ - { - Name: "ResourceRatioCPU", - Weight: 1, - }, - { - Name: "ResourceRatioMemory", - Weight: 1, - }, - }, - } - - //Creating the clusters with resources - assertBindingClusterSet(clusterSet1Name) - assertCreatingClustersWithNames(clusterSet1Name, clusterNames) - for i, name := range clusterNames { - assertUpdatingClusterWithClusterResources(name, clusterResources[i]) - } - - //Checking the result of the placement - assertCreatingPlacement(placementName, noc(2), 2, prioritizerPolicy) - assertClusterNamesOfDecisions(placementName, []string{clusterNames[1], clusterNames[2]}) - - }) - - ginkgo.It("Should schedule successfully based on default SchedulePolicy ResourceAllocatableCPU & ResourceAllocatableMemory", func() { + ginkgo.It("Should schedule successfully based on SchedulePolicy ResourceAllocatableCPU & ResourceAllocatableMemory", func() { // cluster settings clusterNames := []string{ clusterName + "-1", @@ -577,11 +537,11 @@ var _ = ginkgo.Describe("Placement", func() { Mode: clusterapiv1alpha1.PrioritizerPolicyModeExact, Configurations: []clusterapiv1alpha1.PrioritizerConfig{ { - Name: "ResourceRatioCPU", + Name: "ResourceAllocatableCPU", Weight: 1, }, { - Name: "ResourceRatioMemory", + Name: "ResourceAllocatableMemory", Weight: 1, }, }, @@ -596,7 +556,7 @@ var _ = ginkgo.Describe("Placement", func() { //Checking the result of the placement assertCreatingPlacement(placementName, noc(2), 2, prioritizerPolicy) - assertClusterNamesOfDecisions(placementName, []string{clusterNames[1], clusterNames[2]}) + assertClusterNamesOfDecisions(placementName, []string{clusterNames[0], clusterNames[2]}) ginkgo.By("Adding a new cluster with resources") clusterNames = append(clusterNames, clusterName+"-4") @@ -609,7 +569,7 @@ var _ = ginkgo.Describe("Placement", func() { }) - ginkgo.It("Should keep steady successfully even placementdecisions' balance and cluster resource changes", func() { + ginkgo.It("Should keep steady successfully even placementdecisions' balance and cluster situation changes", func() { // cluster settings clusterNames := []string{ clusterName + "-1", @@ -630,11 +590,11 @@ var _ = ginkgo.Describe("Placement", func() { Weight: 3, }, { - Name: "ResourceRatioCPU", + Name: "ResourceAllocatableCPU", Weight: 1, }, { - Name: "ResourceRatioMemory", + Name: "ResourceAllocatableMemory", Weight: 1, }, }, @@ -648,14 +608,18 @@ var _ = ginkgo.Describe("Placement", func() { //Checking the result of the placement assertCreatingPlacement(placementName, noc(2), 2, prioritizerPolicy) - assertClusterNamesOfDecisions(placementName, []string{clusterNames[1], clusterNames[2]}) + assertClusterNamesOfDecisions(placementName, []string{clusterNames[0], clusterNames[2]}) - ginkgo.By("Adding fake placement decisions and update cluster resources") + ginkgo.By("Adding fake placement decisions") assertCreatingPlacementDecision(placementName+"-1", []string{clusterNames[1]}) - assertUpdatingClusterWithClusterResources(clusterNames[0], []string{"10", "10", "10", "100"}) + ginkgo.By("Adding a new cluster with resources") + clusterNames = append(clusterNames, clusterName+"-4") + newClusterResources := []string{"10", "10", "100", "100"} + assertCreatingClustersWithNames(clusterSet1Name, clusterNames[3:4]) + assertUpdatingClusterWithClusterResources(clusterNames[3], newClusterResources) //Checking the result of the placement - assertClusterNamesOfDecisions(placementName, []string{clusterNames[1], clusterNames[2]}) + assertClusterNamesOfDecisions(placementName, []string{clusterNames[0], clusterNames[2]}) }) }) }) diff --git a/vendor/modules.txt b/vendor/modules.txt index 83b9435d7..df29abc7c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -860,7 +860,7 @@ k8s.io/utils/net k8s.io/utils/path k8s.io/utils/pointer k8s.io/utils/trace -# open-cluster-management.io/api v0.0.0-20210916013819-2e58cdb938f9 +# open-cluster-management.io/api v0.0.0-20210927063308-2c6896161c48 ## explicit open-cluster-management.io/api/client/cluster/clientset/versioned open-cluster-management.io/api/client/cluster/clientset/versioned/fake diff --git a/vendor/open-cluster-management.io/api/cluster/v1alpha1/0000_03_clusters.open-cluster-management.io_placements.crd.yaml b/vendor/open-cluster-management.io/api/cluster/v1alpha1/0000_03_clusters.open-cluster-management.io_placements.crd.yaml index f119d84c2..abeb63876 100644 --- a/vendor/open-cluster-management.io/api/cluster/v1alpha1/0000_03_clusters.open-cluster-management.io_placements.crd.yaml +++ b/vendor/open-cluster-management.io/api/cluster/v1alpha1/0000_03_clusters.open-cluster-management.io_placements.crd.yaml @@ -212,9 +212,7 @@ spec: description: 'Name is the name of a prioritizer. Below are the valid names: 1) Balance: balance the decisions among the clusters. 2) Steady: ensure the existing decision - is stabilized. 3) ResourceRatioCPU & ResourceRatioMemory: - sort clusters based on the allocatable to capacity ratio. - 4) ResourceAllocatableCPU & ResourceAllocatableMemory: + is stabilized. 3) ResourceAllocatableCPU & ResourceAllocatableMemory: sort clusters based on the allocatable.' type: string weight: diff --git a/vendor/open-cluster-management.io/api/cluster/v1alpha1/types.go b/vendor/open-cluster-management.io/api/cluster/v1alpha1/types.go index 789208987..06a5cc5c6 100644 --- a/vendor/open-cluster-management.io/api/cluster/v1alpha1/types.go +++ b/vendor/open-cluster-management.io/api/cluster/v1alpha1/types.go @@ -304,8 +304,7 @@ type PrioritizerConfig struct { // Name is the name of a prioritizer. Below are the valid names: // 1) Balance: balance the decisions among the clusters. // 2) Steady: ensure the existing decision is stabilized. - // 3) ResourceRatioCPU & ResourceRatioMemory: sort clusters based on the allocatable to capacity ratio. - // 4) ResourceAllocatableCPU & ResourceAllocatableMemory: sort clusters based on the allocatable. + // 3) ResourceAllocatableCPU & ResourceAllocatableMemory: sort clusters based on the allocatable. // +kubebuilder:validation:Required // +required Name string `json:"name"` diff --git a/vendor/open-cluster-management.io/api/cluster/v1alpha1/zz_generated.swagger_doc_generated.go b/vendor/open-cluster-management.io/api/cluster/v1alpha1/zz_generated.swagger_doc_generated.go index 52c79b5ae..f5b21e079 100644 --- a/vendor/open-cluster-management.io/api/cluster/v1alpha1/zz_generated.swagger_doc_generated.go +++ b/vendor/open-cluster-management.io/api/cluster/v1alpha1/zz_generated.swagger_doc_generated.go @@ -212,7 +212,7 @@ func (PlacementStatus) SwaggerDoc() map[string]string { var map_PrioritizerConfig = map[string]string{ "": "PrioritizerConfig represents the configuration of prioritizer", - "name": "Name is the name of a prioritizer. Below are the valid names: 1) Balance: balance the decisions among the clusters. 2) Steady: ensure the existing decision is stabilized. 3) ResourceRatioCPU & ResourceRatioMemory: sort clusters based on the allocatable to capacity ratio. 4) ResourceAllocatableCPU & ResourceAllocatableMemory: sort clusters based on the allocatable.", + "name": "Name is the name of a prioritizer. Below are the valid names: 1) Balance: balance the decisions among the clusters. 2) Steady: ensure the existing decision is stabilized. 3) ResourceAllocatableCPU & ResourceAllocatableMemory: sort clusters based on the allocatable.", "weight": "Weight defines the weight of prioritizer. The value must be ranged in [0,10]. Each prioritizer will calculate an integer score of a cluster in the range of [-100, 100]. The final score of a cluster will be sum(weight * prioritizer_score). A higher weight indicates that the prioritizer weights more in the cluster selection, while 0 weight indicate thats the prioritizer is disabled.", }