mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-28 13:03:43 +00:00
Merge pull request #84073 from draveness/feature/cleanup-framework-plugins
feat: several cleanups in the scheduling package
This commit is contained in:
commit
422256110e
@ -39,7 +39,7 @@ func (s sortablePods) Less(i, j int) bool {
|
||||
func (s sortablePods) Len() int { return len(s) }
|
||||
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.
|
||||
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) 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.
|
||||
// Note: this function does not compare podRequest.
|
||||
|
@ -28,8 +28,8 @@ import (
|
||||
// extension points. It communicates through state with another function.
|
||||
type CommunicatingPlugin struct{}
|
||||
|
||||
var _ = framework.ReservePlugin(CommunicatingPlugin{})
|
||||
var _ = framework.PreBindPlugin(CommunicatingPlugin{})
|
||||
var _ framework.ReservePlugin = CommunicatingPlugin{}
|
||||
var _ framework.PreBindPlugin = CommunicatingPlugin{}
|
||||
|
||||
// Name is the name of the plug used in Registry and configurations.
|
||||
const Name = "multipoint-communicating-plugin"
|
||||
|
@ -29,7 +29,7 @@ import (
|
||||
// and implements only one hook for prebind.
|
||||
type StatelessPreBindExample struct{}
|
||||
|
||||
var _ = framework.PreBindPlugin(StatelessPreBindExample{})
|
||||
var _ framework.PreBindPlugin = StatelessPreBindExample{}
|
||||
|
||||
// Name is the name of the plugin used in Registry and configurations.
|
||||
const Name = "stateless-prebind-plugin-example"
|
||||
|
@ -36,8 +36,8 @@ type MultipointExample struct {
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
var _ = framework.ReservePlugin(&MultipointExample{})
|
||||
var _ = framework.PreBindPlugin(&MultipointExample{})
|
||||
var _ framework.ReservePlugin = &MultipointExample{}
|
||||
var _ framework.PreBindPlugin = &MultipointExample{}
|
||||
|
||||
// Name is the name of the plug used in Registry and configurations.
|
||||
const Name = "multipoint-plugin-example"
|
||||
|
@ -29,12 +29,12 @@ import (
|
||||
|
||||
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 {
|
||||
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.
|
||||
const Name = "ImageLocality"
|
||||
|
@ -30,7 +30,7 @@ import (
|
||||
// NodeName is a plugin that checks if a pod spec node name matches the current node.
|
||||
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.
|
||||
const Name = "NodeName"
|
||||
|
@ -32,14 +32,12 @@ func TestNodeName(t *testing.T) {
|
||||
tests := []struct {
|
||||
pod *v1.Pod
|
||||
node *v1.Node
|
||||
fits bool
|
||||
name string
|
||||
wantStatus *framework.Status
|
||||
}{
|
||||
{
|
||||
pod: &v1.Pod{},
|
||||
node: &v1.Node{},
|
||||
fits: true,
|
||||
name: "no host specified",
|
||||
},
|
||||
{
|
||||
@ -53,7 +51,6 @@ func TestNodeName(t *testing.T) {
|
||||
Name: "foo",
|
||||
},
|
||||
},
|
||||
fits: true,
|
||||
name: "host matches",
|
||||
},
|
||||
{
|
||||
@ -67,7 +64,6 @@ func TestNodeName(t *testing.T) {
|
||||
Name: "foo",
|
||||
},
|
||||
},
|
||||
fits: false,
|
||||
name: "host doesn't match",
|
||||
wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, predicates.ErrPodNotMatchHostName.GetReason()),
|
||||
},
|
||||
|
@ -30,7 +30,7 @@ import (
|
||||
// NodePorts is a plugin that checks if a node has free ports for the requested pod ports.
|
||||
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.
|
||||
const Name = "NodePorts"
|
||||
|
@ -31,7 +31,7 @@ import (
|
||||
// NodeResources is a plugin that checks if a node has sufficient resources.
|
||||
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.
|
||||
const Name = "NodeResources"
|
||||
|
@ -19,7 +19,7 @@ package nodevolumelimits
|
||||
import (
|
||||
"context"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/kubernetes/pkg/scheduler/algorithm/predicates"
|
||||
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/migration"
|
||||
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
|
||||
@ -31,7 +31,7 @@ type NodeVolumeLimits struct {
|
||||
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.
|
||||
const Name = "NodeVolumeLimits"
|
||||
|
@ -34,8 +34,8 @@ type TaintToleration struct {
|
||||
handle framework.FrameworkHandle
|
||||
}
|
||||
|
||||
var _ = framework.FilterPlugin(&TaintToleration{})
|
||||
var _ = framework.ScorePlugin(&TaintToleration{})
|
||||
var _ framework.FilterPlugin = &TaintToleration{}
|
||||
var _ framework.ScorePlugin = &TaintToleration{}
|
||||
|
||||
// Name is the name of the plugin used in the plugin registry and configurations.
|
||||
const Name = "TaintToleration"
|
||||
|
@ -27,10 +27,10 @@ import (
|
||||
"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{}
|
||||
|
||||
var _ = framework.FilterPlugin(&VolumeRestrictions{})
|
||||
var _ framework.FilterPlugin = &VolumeRestrictions{}
|
||||
|
||||
// Name is the name of the plugin used in the plugin registry and configurations.
|
||||
const Name = "VolumeRestrictions"
|
||||
|
@ -26,12 +26,12 @@ import (
|
||||
"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 {
|
||||
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.
|
||||
const Name = "VolumeZone"
|
||||
|
@ -127,7 +127,7 @@ func WithInformerFactory(informerFactory informers.SharedInformerFactory) Option
|
||||
|
||||
var defaultFrameworkOptions = frameworkOptions{}
|
||||
|
||||
var _ = Framework(&framework{})
|
||||
var _ Framework = &framework{}
|
||||
|
||||
// NewFramework initializes plugins given the configuration and the registry.
|
||||
func NewFramework(r Registry, plugins *config.Plugins, args []config.PluginConfig, opts ...Option) (Framework, error) {
|
||||
|
@ -47,8 +47,8 @@ const (
|
||||
|
||||
// TestScoreWithNormalizePlugin implements ScoreWithNormalizePlugin interface.
|
||||
// TestScorePlugin only implements ScorePlugin interface.
|
||||
var _ = ScorePlugin(&TestScoreWithNormalizePlugin{})
|
||||
var _ = ScorePlugin(&TestScorePlugin{})
|
||||
var _ ScorePlugin = &TestScoreWithNormalizePlugin{}
|
||||
var _ ScorePlugin = &TestScorePlugin{}
|
||||
|
||||
func newScoreWithNormalizePlugin1(injArgs *runtime.Unknown, f FrameworkHandle) (Plugin, error) {
|
||||
var inj injectedResult
|
||||
|
@ -187,7 +187,7 @@ var defaultPriorityQueueOptions = priorityQueueOptions{
|
||||
}
|
||||
|
||||
// Making sure that PriorityQueue implements SchedulingQueue.
|
||||
var _ = SchedulingQueue(&PriorityQueue{})
|
||||
var _ SchedulingQueue = &PriorityQueue{}
|
||||
|
||||
// newPodInfoNoTimestamp builds a PodInfo object without timestamp.
|
||||
func newPodInfoNoTimestamp(pod *v1.Pod) *framework.PodInfo {
|
||||
|
@ -116,18 +116,18 @@ const (
|
||||
permitPluginName = "permit-plugin"
|
||||
)
|
||||
|
||||
var _ = framework.PreFilterPlugin(&PreFilterPlugin{})
|
||||
var _ = framework.ScorePlugin(&ScorePlugin{})
|
||||
var _ = framework.FilterPlugin(&FilterPlugin{})
|
||||
var _ = framework.ScorePlugin(&ScorePlugin{})
|
||||
var _ = framework.ScorePlugin(&ScoreWithNormalizePlugin{})
|
||||
var _ = framework.ReservePlugin(&ReservePlugin{})
|
||||
var _ = framework.PostFilterPlugin(&PostFilterPlugin{})
|
||||
var _ = framework.PreBindPlugin(&PreBindPlugin{})
|
||||
var _ = framework.BindPlugin(&BindPlugin{})
|
||||
var _ = framework.PostBindPlugin(&PostBindPlugin{})
|
||||
var _ = framework.UnreservePlugin(&UnreservePlugin{})
|
||||
var _ = framework.PermitPlugin(&PermitPlugin{})
|
||||
var _ framework.PreFilterPlugin = &PreFilterPlugin{}
|
||||
var _ framework.ScorePlugin = &ScorePlugin{}
|
||||
var _ framework.FilterPlugin = &FilterPlugin{}
|
||||
var _ framework.ScorePlugin = &ScorePlugin{}
|
||||
var _ framework.ScorePlugin = &ScoreWithNormalizePlugin{}
|
||||
var _ framework.ReservePlugin = &ReservePlugin{}
|
||||
var _ framework.PostFilterPlugin = &PostFilterPlugin{}
|
||||
var _ framework.PreBindPlugin = &PreBindPlugin{}
|
||||
var _ framework.BindPlugin = &BindPlugin{}
|
||||
var _ framework.PostBindPlugin = &PostBindPlugin{}
|
||||
var _ framework.UnreservePlugin = &UnreservePlugin{}
|
||||
var _ framework.PermitPlugin = &PermitPlugin{}
|
||||
|
||||
// newPlugin returns a plugin factory with specified Plugin.
|
||||
func newPlugin(plugin framework.Plugin) framework.PluginFactory {
|
||||
|
@ -118,7 +118,7 @@ func (fp *tokenFilter) PreFilterExtensions() framework.PreFilterExtensions {
|
||||
return fp
|
||||
}
|
||||
|
||||
var _ = framework.FilterPlugin(&tokenFilter{})
|
||||
var _ framework.FilterPlugin = &tokenFilter{}
|
||||
|
||||
// TestPreemption tests a few preemption scenarios.
|
||||
func TestPreemption(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user