Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: several cleanups in the scheduling package #84073

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/scheduler/algorithm/predicates/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions pkg/scheduler/framework/plugins/examples/stateful/stateful.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/framework/plugins/nodename/node_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 0 additions & 4 deletions pkg/scheduler/framework/plugins/nodename/node_name_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
{
Expand All @@ -53,7 +51,6 @@ func TestNodeName(t *testing.T) {
Name: "foo",
},
},
fits: true,
name: "host matches",
},
{
Expand All @@ -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()),
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/framework/plugins/nodeports/node_ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions pkg/scheduler/framework/plugins/volumezone/volume_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/framework/v1alpha1/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/scheduler/framework/v1alpha1/framework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/internal/queue/scheduling_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 12 additions & 12 deletions test/integration/scheduler/framework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/scheduler/preemption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down