Merge pull request #84073 from draveness/feature/cleanup-framework-plugins

feat: several cleanups in the scheduling package
This commit is contained in:
Kubernetes Prow Robot 2019-10-18 04:43:57 -07:00 committed by GitHub
commit 422256110e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 37 additions and 41 deletions

View File

@ -39,7 +39,7 @@ func (s sortablePods) Less(i, j int) bool {
func (s sortablePods) Len() int { return len(s) } func (s sortablePods) Len() int { return len(s) }
func (s sortablePods) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s sortablePods) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
var _ = sort.Interface(&sortablePods{}) var _ sort.Interface = &sortablePods{}
// sortableServices allows us to sort services. // sortableServices allows us to sort services.
type sortableServices []*v1.Service type sortableServices []*v1.Service
@ -51,7 +51,7 @@ func (s sortableServices) Less(i, j int) bool {
func (s sortableServices) Len() int { return len(s) } func (s sortableServices) Len() int { return len(s) }
func (s sortableServices) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s sortableServices) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
var _ = sort.Interface(&sortableServices{}) var _ sort.Interface = &sortableServices{}
// predicateMetadataEquivalent returns true if the two metadata are equivalent. // predicateMetadataEquivalent returns true if the two metadata are equivalent.
// Note: this function does not compare podRequest. // Note: this function does not compare podRequest.

View File

@ -28,8 +28,8 @@ import (
// extension points. It communicates through state with another function. // extension points. It communicates through state with another function.
type CommunicatingPlugin struct{} type CommunicatingPlugin struct{}
var _ = framework.ReservePlugin(CommunicatingPlugin{}) var _ framework.ReservePlugin = CommunicatingPlugin{}
var _ = framework.PreBindPlugin(CommunicatingPlugin{}) var _ framework.PreBindPlugin = CommunicatingPlugin{}
// Name is the name of the plug used in Registry and configurations. // Name is the name of the plug used in Registry and configurations.
const Name = "multipoint-communicating-plugin" const Name = "multipoint-communicating-plugin"

View File

@ -29,7 +29,7 @@ import (
// and implements only one hook for prebind. // and implements only one hook for prebind.
type StatelessPreBindExample struct{} type StatelessPreBindExample struct{}
var _ = framework.PreBindPlugin(StatelessPreBindExample{}) var _ framework.PreBindPlugin = StatelessPreBindExample{}
// Name is the name of the plugin used in Registry and configurations. // Name is the name of the plugin used in Registry and configurations.
const Name = "stateless-prebind-plugin-example" const Name = "stateless-prebind-plugin-example"

View File

@ -36,8 +36,8 @@ type MultipointExample struct {
mu sync.RWMutex mu sync.RWMutex
} }
var _ = framework.ReservePlugin(&MultipointExample{}) var _ framework.ReservePlugin = &MultipointExample{}
var _ = framework.PreBindPlugin(&MultipointExample{}) var _ framework.PreBindPlugin = &MultipointExample{}
// Name is the name of the plug used in Registry and configurations. // Name is the name of the plug used in Registry and configurations.
const Name = "multipoint-plugin-example" const Name = "multipoint-plugin-example"

View File

@ -29,12 +29,12 @@ import (
var mb int64 = 1024 * 1024 var mb int64 = 1024 * 1024
// ImageLocality is a plugin that checks if a pod tolerates a node's taints. // ImageLocality is a score plugin that favors nodes that already have requested pod container's images.
type ImageLocality struct { type ImageLocality struct {
handle framework.FrameworkHandle handle framework.FrameworkHandle
} }
var _ = framework.ScorePlugin(&ImageLocality{}) var _ framework.ScorePlugin = &ImageLocality{}
// Name is the name of the plugin used in the plugin registry and configurations. // Name is the name of the plugin used in the plugin registry and configurations.
const Name = "ImageLocality" const Name = "ImageLocality"

View File

@ -30,7 +30,7 @@ import (
// NodeName is a plugin that checks if a pod spec node name matches the current node. // NodeName is a plugin that checks if a pod spec node name matches the current node.
type NodeName struct{} type NodeName struct{}
var _ = framework.FilterPlugin(&NodeName{}) var _ framework.FilterPlugin = &NodeName{}
// Name is the name of the plugin used in the plugin registry and configurations. // Name is the name of the plugin used in the plugin registry and configurations.
const Name = "NodeName" const Name = "NodeName"

View File

@ -32,14 +32,12 @@ func TestNodeName(t *testing.T) {
tests := []struct { tests := []struct {
pod *v1.Pod pod *v1.Pod
node *v1.Node node *v1.Node
fits bool
name string name string
wantStatus *framework.Status wantStatus *framework.Status
}{ }{
{ {
pod: &v1.Pod{}, pod: &v1.Pod{},
node: &v1.Node{}, node: &v1.Node{},
fits: true,
name: "no host specified", name: "no host specified",
}, },
{ {
@ -53,7 +51,6 @@ func TestNodeName(t *testing.T) {
Name: "foo", Name: "foo",
}, },
}, },
fits: true,
name: "host matches", name: "host matches",
}, },
{ {
@ -67,7 +64,6 @@ func TestNodeName(t *testing.T) {
Name: "foo", Name: "foo",
}, },
}, },
fits: false,
name: "host doesn't match", name: "host doesn't match",
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, predicates.ErrPodNotMatchHostName.GetReason()), wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, predicates.ErrPodNotMatchHostName.GetReason()),
}, },

View File

@ -30,7 +30,7 @@ import (
// NodePorts is a plugin that checks if a node has free ports for the requested pod ports. // NodePorts is a plugin that checks if a node has free ports for the requested pod ports.
type NodePorts struct{} type NodePorts struct{}
var _ = framework.FilterPlugin(&NodePorts{}) var _ framework.FilterPlugin = &NodePorts{}
// Name is the name of the plugin used in the plugin registry and configurations. // Name is the name of the plugin used in the plugin registry and configurations.
const Name = "NodePorts" const Name = "NodePorts"

View File

@ -31,7 +31,7 @@ import (
// NodeResources is a plugin that checks if a node has sufficient resources. // NodeResources is a plugin that checks if a node has sufficient resources.
type NodeResources struct{} type NodeResources struct{}
var _ = framework.FilterPlugin(&NodeResources{}) var _ framework.FilterPlugin = &NodeResources{}
// Name is the name of the plugin used in the plugin registry and configurations. // Name is the name of the plugin used in the plugin registry and configurations.
const Name = "NodeResources" const Name = "NodeResources"

View File

@ -19,7 +19,7 @@ package nodevolumelimits
import ( import (
"context" "context"
"k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
"k8s.io/kubernetes/pkg/scheduler/algorithm/predicates" "k8s.io/kubernetes/pkg/scheduler/algorithm/predicates"
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/migration" "k8s.io/kubernetes/pkg/scheduler/framework/plugins/migration"
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1" framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
@ -31,7 +31,7 @@ type NodeVolumeLimits struct {
predicate predicates.FitPredicate predicate predicates.FitPredicate
} }
var _ = framework.FilterPlugin(&NodeVolumeLimits{}) var _ framework.FilterPlugin = &NodeVolumeLimits{}
// Name is the name of the plugin used in the plugin registry and configurations. // Name is the name of the plugin used in the plugin registry and configurations.
const Name = "NodeVolumeLimits" const Name = "NodeVolumeLimits"

View File

@ -34,8 +34,8 @@ type TaintToleration struct {
handle framework.FrameworkHandle handle framework.FrameworkHandle
} }
var _ = framework.FilterPlugin(&TaintToleration{}) var _ framework.FilterPlugin = &TaintToleration{}
var _ = framework.ScorePlugin(&TaintToleration{}) var _ framework.ScorePlugin = &TaintToleration{}
// Name is the name of the plugin used in the plugin registry and configurations. // Name is the name of the plugin used in the plugin registry and configurations.
const Name = "TaintToleration" const Name = "TaintToleration"

View File

@ -27,10 +27,10 @@ import (
"k8s.io/kubernetes/pkg/scheduler/nodeinfo" "k8s.io/kubernetes/pkg/scheduler/nodeinfo"
) )
// VolumeRestrictions is a plugin that checks volume restrictions // VolumeRestrictions is a plugin that checks volume restrictions.
type VolumeRestrictions struct{} type VolumeRestrictions struct{}
var _ = framework.FilterPlugin(&VolumeRestrictions{}) var _ framework.FilterPlugin = &VolumeRestrictions{}
// Name is the name of the plugin used in the plugin registry and configurations. // Name is the name of the plugin used in the plugin registry and configurations.
const Name = "VolumeRestrictions" const Name = "VolumeRestrictions"

View File

@ -26,12 +26,12 @@ import (
"k8s.io/kubernetes/pkg/scheduler/nodeinfo" "k8s.io/kubernetes/pkg/scheduler/nodeinfo"
) )
// VolumeZone is a plugin that checks volume zone // VolumeZone is a plugin that checks volume zone.
type VolumeZone struct { type VolumeZone struct {
predicate predicates.FitPredicate predicate predicates.FitPredicate
} }
var _ = framework.FilterPlugin(&VolumeZone{}) var _ framework.FilterPlugin = &VolumeZone{}
// Name is the name of the plugin used in the plugin registry and configurations. // Name is the name of the plugin used in the plugin registry and configurations.
const Name = "VolumeZone" const Name = "VolumeZone"

View File

@ -127,7 +127,7 @@ func WithInformerFactory(informerFactory informers.SharedInformerFactory) Option
var defaultFrameworkOptions = frameworkOptions{} var defaultFrameworkOptions = frameworkOptions{}
var _ = Framework(&framework{}) var _ Framework = &framework{}
// NewFramework initializes plugins given the configuration and the registry. // NewFramework initializes plugins given the configuration and the registry.
func NewFramework(r Registry, plugins *config.Plugins, args []config.PluginConfig, opts ...Option) (Framework, error) { func NewFramework(r Registry, plugins *config.Plugins, args []config.PluginConfig, opts ...Option) (Framework, error) {

View File

@ -47,8 +47,8 @@ const (
// TestScoreWithNormalizePlugin implements ScoreWithNormalizePlugin interface. // TestScoreWithNormalizePlugin implements ScoreWithNormalizePlugin interface.
// TestScorePlugin only implements ScorePlugin interface. // TestScorePlugin only implements ScorePlugin interface.
var _ = ScorePlugin(&TestScoreWithNormalizePlugin{}) var _ ScorePlugin = &TestScoreWithNormalizePlugin{}
var _ = ScorePlugin(&TestScorePlugin{}) var _ ScorePlugin = &TestScorePlugin{}
func newScoreWithNormalizePlugin1(injArgs *runtime.Unknown, f FrameworkHandle) (Plugin, error) { func newScoreWithNormalizePlugin1(injArgs *runtime.Unknown, f FrameworkHandle) (Plugin, error) {
var inj injectedResult var inj injectedResult

View File

@ -187,7 +187,7 @@ var defaultPriorityQueueOptions = priorityQueueOptions{
} }
// Making sure that PriorityQueue implements SchedulingQueue. // Making sure that PriorityQueue implements SchedulingQueue.
var _ = SchedulingQueue(&PriorityQueue{}) var _ SchedulingQueue = &PriorityQueue{}
// newPodInfoNoTimestamp builds a PodInfo object without timestamp. // newPodInfoNoTimestamp builds a PodInfo object without timestamp.
func newPodInfoNoTimestamp(pod *v1.Pod) *framework.PodInfo { func newPodInfoNoTimestamp(pod *v1.Pod) *framework.PodInfo {

View File

@ -116,18 +116,18 @@ const (
permitPluginName = "permit-plugin" permitPluginName = "permit-plugin"
) )
var _ = framework.PreFilterPlugin(&PreFilterPlugin{}) var _ framework.PreFilterPlugin = &PreFilterPlugin{}
var _ = framework.ScorePlugin(&ScorePlugin{}) var _ framework.ScorePlugin = &ScorePlugin{}
var _ = framework.FilterPlugin(&FilterPlugin{}) var _ framework.FilterPlugin = &FilterPlugin{}
var _ = framework.ScorePlugin(&ScorePlugin{}) var _ framework.ScorePlugin = &ScorePlugin{}
var _ = framework.ScorePlugin(&ScoreWithNormalizePlugin{}) var _ framework.ScorePlugin = &ScoreWithNormalizePlugin{}
var _ = framework.ReservePlugin(&ReservePlugin{}) var _ framework.ReservePlugin = &ReservePlugin{}
var _ = framework.PostFilterPlugin(&PostFilterPlugin{}) var _ framework.PostFilterPlugin = &PostFilterPlugin{}
var _ = framework.PreBindPlugin(&PreBindPlugin{}) var _ framework.PreBindPlugin = &PreBindPlugin{}
var _ = framework.BindPlugin(&BindPlugin{}) var _ framework.BindPlugin = &BindPlugin{}
var _ = framework.PostBindPlugin(&PostBindPlugin{}) var _ framework.PostBindPlugin = &PostBindPlugin{}
var _ = framework.UnreservePlugin(&UnreservePlugin{}) var _ framework.UnreservePlugin = &UnreservePlugin{}
var _ = framework.PermitPlugin(&PermitPlugin{}) var _ framework.PermitPlugin = &PermitPlugin{}
// newPlugin returns a plugin factory with specified Plugin. // newPlugin returns a plugin factory with specified Plugin.
func newPlugin(plugin framework.Plugin) framework.PluginFactory { func newPlugin(plugin framework.Plugin) framework.PluginFactory {

View File

@ -118,7 +118,7 @@ func (fp *tokenFilter) PreFilterExtensions() framework.PreFilterExtensions {
return fp return fp
} }
var _ = framework.FilterPlugin(&tokenFilter{}) var _ framework.FilterPlugin = &tokenFilter{}
// TestPreemption tests a few preemption scenarios. // TestPreemption tests a few preemption scenarios.
func TestPreemption(t *testing.T) { func TestPreemption(t *testing.T) {