Merge pull request #2170 from RainbowMango/pr_rename_plugin
Rename scheduler plugin name
This commit is contained in:
commit
ab0883e73d
|
@ -1,4 +1,4 @@
|
|||
package apiinstalled
|
||||
package apienablement
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
@ -14,26 +14,26 @@ import (
|
|||
|
||||
const (
|
||||
// Name is the name of the plugin used in the plugin registry and configurations.
|
||||
Name = "APIInstalled"
|
||||
Name = "APIEnablement"
|
||||
)
|
||||
|
||||
// APIInstalled is a plugin that checks if the API(CRD) of the resource is installed in the target cluster.
|
||||
type APIInstalled struct{}
|
||||
// APIEnablement is a plugin that checks if the API(CRD) of the resource is installed in the target cluster.
|
||||
type APIEnablement struct{}
|
||||
|
||||
var _ framework.FilterPlugin = &APIInstalled{}
|
||||
var _ framework.FilterPlugin = &APIEnablement{}
|
||||
|
||||
// New instantiates the APIInstalled plugin.
|
||||
// New instantiates the APIEnablement plugin.
|
||||
func New() (framework.Plugin, error) {
|
||||
return &APIInstalled{}, nil
|
||||
return &APIEnablement{}, nil
|
||||
}
|
||||
|
||||
// Name returns the plugin name.
|
||||
func (p *APIInstalled) Name() string {
|
||||
func (p *APIEnablement) Name() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
// Filter checks if the API(CRD) of the resource is installed in the target cluster.
|
||||
func (p *APIInstalled) Filter(ctx context.Context, placement *policyv1alpha1.Placement, resource *workv1alpha2.ObjectReference, cluster *clusterv1alpha1.Cluster) *framework.Result {
|
||||
// Filter checks if the API(CRD) of the resource is enabled or installed in the target cluster.
|
||||
func (p *APIEnablement) Filter(ctx context.Context, placement *policyv1alpha1.Placement, resource *workv1alpha2.ObjectReference, cluster *clusterv1alpha1.Cluster) *framework.Result {
|
||||
if !helper.IsAPIEnabled(cluster.Status.APIEnablements, resource.APIVersion, resource.Kind) {
|
||||
klog.V(2).Infof("Cluster(%s) not fit as missing API(%s, kind=%s)", cluster.Name, resource.APIVersion, resource.Kind)
|
||||
return framework.NewResult(framework.Unschedulable, "no such API resource")
|
|
@ -15,12 +15,12 @@ const (
|
|||
Name = "ClusterLocality"
|
||||
)
|
||||
|
||||
// ClusterLocality is a score plugin that favors cluster that already have requested.
|
||||
// ClusterLocality is a score plugin that favors cluster that already have the resource.
|
||||
type ClusterLocality struct{}
|
||||
|
||||
var _ framework.ScorePlugin = &ClusterLocality{}
|
||||
|
||||
// New instantiates the clusteraffinity plugin.
|
||||
// New instantiates the ClusterLocality plugin.
|
||||
func New() (framework.Plugin, error) {
|
||||
return &ClusterLocality{}, nil
|
||||
}
|
||||
|
@ -31,7 +31,8 @@ func (p *ClusterLocality) Name() string {
|
|||
}
|
||||
|
||||
// Score calculates the score on the candidate cluster.
|
||||
// if cluster object is exist in resourceBinding.Spec.Clusters, Score is 100, otherwise it is 0.
|
||||
// If the cluster already have the resource(exists in .spec.Clusters of ResourceBinding or ClusterResourceBinding),
|
||||
// then score is 100, otherwise 0.
|
||||
func (p *ClusterLocality) Score(ctx context.Context, placement *policyv1alpha1.Placement,
|
||||
spec *workv1alpha2.ResourceBindingSpec, cluster *clusterv1alpha1.Cluster) (int64, *framework.Result) {
|
||||
if len(spec.Clusters) == 0 {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package plugins
|
||||
|
||||
import (
|
||||
"github.com/karmada-io/karmada/pkg/scheduler/framework/plugins/apiinstalled"
|
||||
"github.com/karmada-io/karmada/pkg/scheduler/framework/plugins/apienablement"
|
||||
"github.com/karmada-io/karmada/pkg/scheduler/framework/plugins/clusteraffinity"
|
||||
"github.com/karmada-io/karmada/pkg/scheduler/framework/plugins/clusterlocality"
|
||||
"github.com/karmada-io/karmada/pkg/scheduler/framework/plugins/spreadconstraint"
|
||||
|
@ -12,7 +12,7 @@ import (
|
|||
// NewInTreeRegistry builds the registry with all the in-tree plugins.
|
||||
func NewInTreeRegistry() runtime.Registry {
|
||||
return runtime.Registry{
|
||||
apiinstalled.Name: apiinstalled.New,
|
||||
apienablement.Name: apienablement.New,
|
||||
tainttoleration.Name: tainttoleration.New,
|
||||
clusteraffinity.Name: clusteraffinity.New,
|
||||
spreadconstraint.Name: spreadconstraint.New,
|
||||
|
|
Loading…
Reference in New Issue