Skip to content

Commit fa4d6d3

Browse files
authored
Merge pull request #4566 from wengyao04/estimator-resoucequota-plugin-part-2
[MVP] add resourcequota plugin in scheduler-estimator: add resourcequota plugin
2 parents 3cf27cc + e0b3e83 commit fa4d6d3

File tree

14 files changed

+1009
-55
lines changed

14 files changed

+1009
-55
lines changed

Diff for: api/openapi-spec/swagger.json

+8
Original file line numberDiff line numberDiff line change
@@ -17952,10 +17952,18 @@
1795217952
"description": "ReplicaRequirements represents the requirements required by each replica.",
1795317953
"type": "object",
1795417954
"properties": {
17955+
"namespace": {
17956+
"description": "Namespace represents the resources namespaces",
17957+
"type": "string"
17958+
},
1795517959
"nodeClaim": {
1795617960
"description": "NodeClaim represents the node claim HardNodeAffinity, NodeSelector and Tolerations required by each replica.",
1795717961
"$ref": "#/definitions/com.github.karmada-io.karmada.pkg.apis.work.v1alpha2.NodeClaim"
1795817962
},
17963+
"priorityClassName": {
17964+
"description": "PriorityClassName represents the resources priorityClassName",
17965+
"type": "string"
17966+
},
1795917967
"resourceRequest": {
1796017968
"description": "ResourceRequest represents the resources required by each replica.",
1796117969
"type": "object",

Diff for: charts/karmada/_crds/bases/work/work.karmada.io_clusterresourcebindings.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,9 @@ spec:
919919
description: ReplicaRequirements represents the requirements required
920920
by each replica.
921921
properties:
922+
namespace:
923+
description: Namespace represents the resources namespaces
924+
type: string
922925
nodeClaim:
923926
description: NodeClaim represents the node claim HardNodeAffinity,
924927
NodeSelector and Tolerations required by each replica.
@@ -1066,6 +1069,9 @@ spec:
10661069
type: object
10671070
type: array
10681071
type: object
1072+
priorityClassName:
1073+
description: PriorityClassName represents the resources priorityClassName
1074+
type: string
10691075
resourceRequest:
10701076
additionalProperties:
10711077
anyOf:

Diff for: charts/karmada/_crds/bases/work/work.karmada.io_resourcebindings.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,9 @@ spec:
919919
description: ReplicaRequirements represents the requirements required
920920
by each replica.
921921
properties:
922+
namespace:
923+
description: Namespace represents the resources namespaces
924+
type: string
922925
nodeClaim:
923926
description: NodeClaim represents the node claim HardNodeAffinity,
924927
NodeSelector and Tolerations required by each replica.
@@ -1066,6 +1069,9 @@ spec:
10661069
type: object
10671070
type: array
10681071
type: object
1072+
priorityClassName:
1073+
description: PriorityClassName represents the resources priorityClassName
1074+
type: string
10691075
resourceRequest:
10701076
additionalProperties:
10711077
anyOf:

Diff for: pkg/apis/work/v1alpha2/binding_types.go

+8
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,14 @@ type ReplicaRequirements struct {
175175
// ResourceRequest represents the resources required by each replica.
176176
// +optional
177177
ResourceRequest corev1.ResourceList `json:"resourceRequest,omitempty"`
178+
179+
// Namespace represents the resources namespaces
180+
// +optional
181+
Namespace string `json:"namespace,omitempty"`
182+
183+
// PriorityClassName represents the resources priorityClassName
184+
// +optional
185+
PriorityClassName string `json:"priorityClassName,omitempty"`
178186
}
179187

180188
// NodeClaim represents the node claim HardNodeAffinity, NodeSelector and Tolerations required by each replica.

Diff for: pkg/estimator/client/accurate.go

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ func (se *SchedulerEstimator) maxAvailableReplicas(ctx context.Context, cluster
9191
}
9292
if replicaRequirements != nil {
9393
req.ReplicaRequirements.ResourceRequest = replicaRequirements.ResourceRequest
94+
req.ReplicaRequirements.Namespace = replicaRequirements.Namespace
95+
req.ReplicaRequirements.PriorityClassName = replicaRequirements.PriorityClassName
9496
if replicaRequirements.NodeClaim != nil {
9597
req.ReplicaRequirements.NodeClaim = &pb.NodeClaim{
9698
NodeAffinity: replicaRequirements.NodeClaim.HardNodeAffinity,

Diff for: pkg/estimator/pb/generated.pb.go

+135-53
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: pkg/estimator/pb/generated.proto

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: pkg/estimator/pb/types.go

+9
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ type ReplicaRequirements struct {
5757
// ResourceRequest represents the resources required by each replica.
5858
// +optional
5959
ResourceRequest corev1.ResourceList `json:"resourceRequest,omitempty" protobuf:"bytes,2,rep,name=resourceRequest,casttype=k8s.io/api/core/v1.ResourceList,castkey=k8s.io/api/core/v1.ResourceName"`
60+
// Namespace represents the namespaces belonged to a ResourceRequest
61+
// +optional
62+
Namespace string `json:"namespace,omitempty" protobuf:"bytes,3,opt,name=namespace"`
63+
// PriorityClassName represents the priority class name for a given ResourceRequest
64+
// Resource quotas are introduced for multi tenants sharing a cluster
65+
// Besides estimate the replica based on nodes' resources, we need to consider the resource quota of a ResourceRequest
66+
// ResourceQuota have an associated set of scopes, one of them is priority class
67+
// +optional
68+
PriorityClassName string `json:"priorityClassName,omitempty" protobuf:"bytes,4,opt,name=priorityClassName"`
6069
}
6170

6271
// MaxAvailableReplicasResponse represents the response that sent by gRPC server to calculate max available replicas.

Diff for: pkg/estimator/server/framework/plugins/registry.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@ limitations under the License.
1717
package plugins
1818

1919
import (
20+
"github.com/karmada-io/karmada/pkg/estimator/server/framework/plugins/resourcequota"
2021
"github.com/karmada-io/karmada/pkg/estimator/server/framework/runtime"
2122
)
2223

2324
// NewInTreeRegistry builds the registry with all the in-tree plugins.
2425
func NewInTreeRegistry() runtime.Registry {
25-
registry := runtime.Registry{}
26+
registry := runtime.Registry{
27+
resourcequota.Name: resourcequota.New,
28+
}
2629
return registry
2730
}

0 commit comments

Comments
 (0)