@@ -33,11 +33,18 @@ type Framework interface {
3333 Handle
3434 // RunEstimateReplicasPlugins runs the set of configured EstimateReplicasPlugins
3535 // for estimating replicas based on the given replicaRequirements.
36- // It returns an integer and an Result.
36+ // It returns an integer and a Result.
3737 // The integer represents the minimum calculated value of estimated replicas from each EstimateReplicasPlugin.
38- // The Result contains code, reasons and error
39- // it is merged from all plugins returned result codes
38+ // The Result contains code, reasons and error.
39+ // It is merged from all plugins' returned result codes.
4040 RunEstimateReplicasPlugins (ctx context.Context , snapshot * schedcache.Snapshot , replicaRequirements * pb.ReplicaRequirements ) (int32 , * Result )
41+ // RunEstimateComponentsPlugins runs the set of configured EstimateComponentsPlugins
42+ // for estimating the maximum number of complete component sets based on the given components.
43+ // It returns an integer and a Result.
44+ // The integer represents the minimum calculated value of estimated component sets from each EstimateComponentsPlugin.
45+ // The Result contains code, reasons and error.
46+ // It is merged from all plugins' returned result codes.
47+ RunEstimateComponentsPlugins (ctx context.Context , snapshot * schedcache.Snapshot , components []pb.Component ) (int32 , * Result )
4148 // TODO(wengyao04): we can add filter and score plugin extension points if needed in the future
4249}
4350
@@ -47,21 +54,34 @@ type Plugin interface {
4754}
4855
4956// EstimateReplicasPlugin is an interface for replica estimation plugins.
50- // These estimators are used to estimate the replicas for a given pb.ReplicaRequirements
57+ // These estimators are used to estimate the replicas for a given pb.ReplicaRequirements.
5158type EstimateReplicasPlugin interface {
5259 Plugin
5360 // Estimate is called for each MaxAvailableReplicas request.
54- // It returns an integer and an error
55- // The integer representing the number of calculated replica for the given replicaRequirements
56- // The Result contains code, reasons and error
57- // it is merged from all plugins returned result codes
61+ // It returns an integer and a Result.
62+ // The integer represents the number of calculated replicas for the given replicaRequirements.
63+ // The Result contains code, reasons and error.
64+ // It is merged from all plugins' returned result codes.
5865 Estimate (ctx context.Context , snapshot * schedcache.Snapshot , replicaRequirements * pb.ReplicaRequirements ) (int32 , * Result )
5966}
6067
68+ // EstimateComponentsPlugin is an interface for component set estimation plugins.
69+ // These estimators are used to estimate the maximum number of complete component sets
70+ // for a given set of components with different replica requirements.
71+ type EstimateComponentsPlugin interface {
72+ Plugin
73+ // EstimateComponents is called for each MaxAvailableComponentSets request.
74+ // It returns an integer and a Result.
75+ // The integer represents the estimated number of complete component sets that can be scheduled.
76+ // The Result contains code, reasons and error.
77+ // It is merged from all plugins' returned result codes.
78+ EstimateComponents (ctx context.Context , snapshot * schedcache.Snapshot , components []pb.Component ) (int32 , * Result )
79+ }
80+
6181// Handle provides data and some tools that plugins can use. It is
6282// passed to the plugin factories at the time of plugin initialization. Plugins
6383// must store and use this handle to call framework functions.
64- // We follow the design pattern as kubernetes scheduler framework
84+ // We follow the design pattern of the Kubernetes scheduler framework.
6585type Handle interface {
6686 ClientSet () clientset.Interface
6787 SharedInformerFactory () informers.SharedInformerFactory
@@ -85,9 +105,9 @@ const (
85105 // NOTE: A nil status is also considered as "Success".
86106 Success Code = iota
87107 // Unschedulable is used when a plugin finds the resource unschedulable.
88- // The accompanying status message should explain why the it is unschedulable.
108+ // The accompanying status message should explain why it is unschedulable.
89109 Unschedulable
90- // Nooperation is used when a plugin is disabled or the plugin list are empty
110+ // Nooperation is used when a plugin is disabled or the plugin list is empty.
91111 Noopperation
92112 // Error is used for internal plugin errors, unexpected input, etc.
93113 Error
@@ -115,8 +135,8 @@ func NewResult(code Code, reasons ...string) *Result {
115135// PluginToResult maps plugin name to Result.
116136type PluginToResult map [string ]* Result
117137
118- // Merge merges the statuses in the map into one. The resulting status code have the following
119- // precedence: Error, Unschedulable, Disabled .
138+ // Merge merges the statuses in the map into one. The resulting status code has the following
139+ // precedence: Error, Unschedulable, Nooperation .
120140func (p PluginToResult ) Merge () * Result {
121141 if len (p ) == 0 {
122142 return NewResult (Noopperation , "plugin results are empty" )
@@ -161,8 +181,8 @@ func (s *Result) IsUnschedulable() bool {
161181 return s != nil && s .code == Unschedulable
162182}
163183
164- // IsNoOperation returns true if "Result" is not nil and Code is "Nooperation"
165- // ToDo (wengyao04): we can remove it once we include node resource estimation as the default plugin in the future
184+ // IsNoOperation returns true if "Result" is not nil and Code is "Nooperation".
185+ // TODO (wengyao04): we can remove it once we include node resource estimation as the default plugin in the future.
166186func (s * Result ) IsNoOperation () bool {
167187 return s != nil && s .code == Noopperation
168188}
0 commit comments