mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-05-22 09:03:35 +00:00
remove prioritizor ResourceRatioCPU and ResourceRatioMemory related code
Signed-off-by: haoqing0110 <qhao@redhat.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
2
go.mod
2
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
|
||||
)
|
||||
|
||||
4
go.sum
4
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=
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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]})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
3
vendor/open-cluster-management.io/api/cluster/v1alpha1/types.go
generated
vendored
3
vendor/open-cluster-management.io/api/cluster/v1alpha1/types.go
generated
vendored
@@ -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"`
|
||||
|
||||
@@ -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.",
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user