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

rename FilterPlugin NodeResources #84121

Merged
merged 1 commit into from
Oct 21, 2019
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
32 changes: 16 additions & 16 deletions pkg/scheduler/api/compatibility/compatibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
wantPlugins: map[string][]kubeschedulerconfig.Plugin{
"FilterPlugin": {
{Name: "NodeUnschedulable"},
{Name: "NodeResources"},
{Name: "NodeResourcesFit"},
{Name: "NodeName"},
{Name: "NodePorts"},
{Name: "NodeAffinity"},
Expand Down Expand Up @@ -104,7 +104,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"FilterPlugin": {
{Name: "NodeUnschedulable"},
{Name: "NodeAffinity"},
{Name: "NodeResources"},
{Name: "NodeResourcesFit"},
{Name: "VolumeRestrictions"},
{Name: "TaintToleration"},
},
Expand Down Expand Up @@ -153,7 +153,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "NodeName"},
{Name: "NodePorts"},
{Name: "NodeAffinity"},
{Name: "NodeResources"},
{Name: "NodeResourcesFit"},
{Name: "VolumeRestrictions"},
{Name: "TaintToleration"},
},
Expand Down Expand Up @@ -212,7 +212,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "NodeName"},
{Name: "NodePorts"},
{Name: "NodeAffinity"},
{Name: "NodeResources"},
{Name: "NodeResourcesFit"},
{Name: "VolumeRestrictions"},
{Name: "TaintToleration"},
{Name: "VolumeZone"},
Expand Down Expand Up @@ -277,7 +277,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "NodeName"},
{Name: "NodePorts"},
{Name: "NodeAffinity"},
{Name: "NodeResources"},
{Name: "NodeResourcesFit"},
{Name: "VolumeRestrictions"},
{Name: "TaintToleration"},
{Name: "VolumeZone"},
Expand Down Expand Up @@ -348,7 +348,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "NodeName"},
{Name: "NodePorts"},
{Name: "NodeAffinity"},
{Name: "NodeResources"},
{Name: "NodeResourcesFit"},
{Name: "VolumeRestrictions"},
{Name: "TaintToleration"},
{Name: "VolumeZone"},
Expand Down Expand Up @@ -430,7 +430,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "NodeName"},
{Name: "NodePorts"},
{Name: "NodeAffinity"},
{Name: "NodeResources"},
{Name: "NodeResourcesFit"},
{Name: "VolumeRestrictions"},
{Name: "TaintToleration"},
{Name: "VolumeZone"},
Expand Down Expand Up @@ -525,7 +525,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "NodeName"},
{Name: "NodePorts"},
{Name: "NodeAffinity"},
{Name: "NodeResources"},
{Name: "NodeResourcesFit"},
{Name: "VolumeRestrictions"},
{Name: "TaintToleration"},
{Name: "VolumeZone"},
Expand Down Expand Up @@ -621,7 +621,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "NodeName"},
{Name: "NodePorts"},
{Name: "NodeAffinity"},
{Name: "NodeResources"},
{Name: "NodeResourcesFit"},
{Name: "VolumeRestrictions"},
{Name: "TaintToleration"},
{Name: "VolumeBinding"},
Expand Down Expand Up @@ -723,7 +723,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "NodeName"},
{Name: "NodePorts"},
{Name: "NodeAffinity"},
{Name: "NodeResources"},
{Name: "NodeResourcesFit"},
{Name: "VolumeRestrictions"},
{Name: "TaintToleration"},
{Name: "VolumeBinding"},
Expand Down Expand Up @@ -838,7 +838,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "NodeName"},
{Name: "NodePorts"},
{Name: "NodeAffinity"},
{Name: "NodeResources"},
{Name: "NodeResourcesFit"},
{Name: "VolumeRestrictions"},
{Name: "TaintToleration"},
{Name: "VolumeBinding"},
Expand Down Expand Up @@ -954,7 +954,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "NodeName"},
{Name: "NodePorts"},
{Name: "NodeAffinity"},
{Name: "NodeResources"},
{Name: "NodeResourcesFit"},
{Name: "VolumeRestrictions"},
{Name: "TaintToleration"},
{Name: "NodeVolumeLimits"},
Expand Down Expand Up @@ -1071,7 +1071,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "NodeName"},
{Name: "NodePorts"},
{Name: "NodeAffinity"},
{Name: "NodeResources"},
{Name: "NodeResourcesFit"},
{Name: "VolumeRestrictions"},
{Name: "TaintToleration"},
{Name: "NodeVolumeLimits"},
Expand Down Expand Up @@ -1192,7 +1192,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
{Name: "NodeName"},
{Name: "NodePorts"},
{Name: "NodeAffinity"},
{Name: "NodeResources"},
{Name: "NodeResourcesFit"},
{Name: "VolumeRestrictions"},
{Name: "TaintToleration"},
{Name: "NodeVolumeLimits"},
Expand Down Expand Up @@ -1230,13 +1230,13 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
seenPredicates := sets.NewString()
seenPriorities := sets.NewString()
mandatoryPredicates := sets.NewString()
generalPredicateFilters := []string{"NodeResources", "NodeName", "NodePorts", "NodeAffinity"}
generalPredicateFilters := []string{"NodeResourcesFit", "NodeName", "NodePorts", "NodeAffinity"}
filterToPredicateMap := map[string]string{
"NodeUnschedulable": "CheckNodeUnschedulable",
"TaintToleration": "PodToleratesNodeTaints",
"NodeName": "HostName",
"NodePorts": "PodFitsHostPorts",
"NodeResources": "PodFitsResources",
"NodeResourcesFit": "PodFitsResources",
"NodeAffinity": "MatchNodeSelector",
"VolumeBinding": "CheckVolumeBinding",
"VolumeRestrictions": "NoDiskConflict",
Expand Down
6 changes: 3 additions & 3 deletions pkg/scheduler/framework/plugins/default_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ func NewDefaultRegistry(args *RegistryArgs) framework.Registry {
return framework.Registry{
imagelocality.Name: imagelocality.New,
tainttoleration.Name: tainttoleration.New,
noderesources.Name: noderesources.New,
nodename.Name: nodename.New,
nodeports.Name: nodeports.New,
nodepreferavoidpods.Name: nodepreferavoidpods.New,
nodeaffinity.Name: nodeaffinity.New,
podtopologyspread.Name: podtopologyspread.New,
nodeunschedulable.Name: nodeunschedulable.New,
noderesources.FitName: noderesources.NewFit,
noderesources.BalancedAllocationName: noderesources.NewBalancedAllocation,
noderesources.MostAllocatedName: noderesources.NewMostAllocated,
noderesources.LeastAllocatedName: noderesources.NewLeastAllocated,
Expand Down Expand Up @@ -105,7 +105,7 @@ func NewDefaultConfigProducerRegistry() *ConfigProducerRegistry {
registry.RegisterPredicate(predicates.GeneralPred,
func(_ ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
// GeneralPredicate is a combination of predicates.
plugins.Filter = appendToPluginSet(plugins.Filter, noderesources.Name, nil)
plugins.Filter = appendToPluginSet(plugins.Filter, noderesources.FitName, nil)
plugins.Filter = appendToPluginSet(plugins.Filter, nodename.Name, nil)
plugins.Filter = appendToPluginSet(plugins.Filter, nodeports.Name, nil)
plugins.Filter = appendToPluginSet(plugins.Filter, nodeaffinity.Name, nil)
Expand All @@ -118,7 +118,7 @@ func NewDefaultConfigProducerRegistry() *ConfigProducerRegistry {
})
registry.RegisterPredicate(predicates.PodFitsResourcesPred,
func(_ ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
plugins.Filter = appendToPluginSet(plugins.Filter, noderesources.Name, nil)
plugins.Filter = appendToPluginSet(plugins.Filter, noderesources.FitName, nil)
return
})
registry.RegisterPredicate(predicates.HostNamePred,
Expand Down
4 changes: 2 additions & 2 deletions pkg/scheduler/framework/plugins/noderesources/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ go_library(
name = "go_default_library",
srcs = [
"balanced_allocation.go",
"fit.go",
"least_allocated.go",
"most_allocated.go",
"node_resources.go",
"test_util.go",
],
importpath = "k8s.io/kubernetes/pkg/scheduler/framework/plugins/noderesources",
Expand Down Expand Up @@ -42,9 +42,9 @@ go_test(
name = "go_default_test",
srcs = [
"balanced_allocation_test.go",
"fit_test.go",
"least_allocated_test.go",
"most_allocated_test.go",
"node_resources_test.go",
],
embed = [":go_default_library"],
deps = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ import (
"k8s.io/kubernetes/pkg/scheduler/nodeinfo"
)

// NodeResources is a plugin that checks if a node has sufficient resources.
type NodeResources struct{}
// Fit is a plugin that checks if a node has sufficient resources.
type Fit struct{}

var _ framework.FilterPlugin = &NodeResources{}
var _ framework.FilterPlugin = &Fit{}

// Name is the name of the plugin used in the plugin registry and configurations.
const Name = "NodeResources"
// FitName is the name of the plugin used in the plugin registry and configurations.
const FitName = "NodeResourcesFit"

// Name returns name of the plugin. It is used in logs, etc.
func (pl *NodeResources) Name() string {
return Name
func (f *Fit) Name() string {
return FitName
}

// Filter invoked at the filter extension point.
func (pl *NodeResources) Filter(ctx context.Context, cycleState *framework.CycleState, pod *v1.Pod, nodeInfo *nodeinfo.NodeInfo) *framework.Status {
func (f *Fit) Filter(ctx context.Context, cycleState *framework.CycleState, pod *v1.Pod, nodeInfo *nodeinfo.NodeInfo) *framework.Status {
meta, ok := migration.PredicateMetadata(cycleState).(predicates.PredicateMetadata)
if !ok {
return migration.ErrorToFrameworkStatus(fmt.Errorf("%+v convert to predicates.PredicateMetadata error", cycleState))
Expand All @@ -51,7 +51,7 @@ func (pl *NodeResources) Filter(ctx context.Context, cycleState *framework.Cycle
return migration.PredicateResultToFrameworkStatus(reasons, err)
}

// New initializes a new plugin and returns it.
func New(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) {
return &NodeResources{}, nil
// NewFit initializes a new plugin and returns it.
func NewFit(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) {
return &Fit{}, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func newResourceOverheadPod(pod *v1.Pod, overhead v1.ResourceList) *v1.Pod {
pod.Spec.Overhead = overhead
return pod
}
func TestNodeResources(t *testing.T) {
func TestNodeResourcesFit(t *testing.T) {
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodOverhead, true)()

enoughPodsTests := []struct {
Expand Down Expand Up @@ -350,7 +350,7 @@ func TestNodeResources(t *testing.T) {
node := v1.Node{Status: v1.NodeStatus{Capacity: makeResources(10, 20, 32, 5, 20, 5).Capacity, Allocatable: makeAllocatableResources(10, 20, 32, 5, 20, 5)}}
test.nodeInfo.SetNode(&node)

p, _ := New(nil, nil)
p, _ := NewFit(nil, nil)
gotStatus := p.(framework.FilterPlugin).Filter(context.Background(), state, test.pod, test.nodeInfo)
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
t.Errorf("status does not match: %v, want: %v", gotStatus, test.wantStatus)
Expand Down Expand Up @@ -403,7 +403,7 @@ func TestNodeResources(t *testing.T) {
node := v1.Node{Status: v1.NodeStatus{Capacity: v1.ResourceList{}, Allocatable: makeAllocatableResources(10, 20, 1, 0, 0, 0)}}
test.nodeInfo.SetNode(&node)

p, _ := New(nil, nil)
p, _ := NewFit(nil, nil)
gotStatus := p.(framework.FilterPlugin).Filter(context.Background(), state, test.pod, test.nodeInfo)
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
t.Errorf("status does not match: %v, want: %v", gotStatus, test.wantStatus)
Expand Down Expand Up @@ -454,7 +454,7 @@ func TestNodeResources(t *testing.T) {
node := v1.Node{Status: v1.NodeStatus{Capacity: makeResources(10, 20, 32, 5, 20, 5).Capacity, Allocatable: makeAllocatableResources(10, 20, 32, 5, 20, 5)}}
test.nodeInfo.SetNode(&node)

p, _ := New(nil, nil)
p, _ := NewFit(nil, nil)
gotStatus := p.(framework.FilterPlugin).Filter(context.Background(), state, test.pod, test.nodeInfo)
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
t.Errorf("status does not match: %v, want: %v", gotStatus, test.wantStatus)
Expand Down
4 changes: 2 additions & 2 deletions test/integration/scheduler/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func TestSchedulerCreationFromConfigMap(t *testing.T) {
expectedPlugins: map[string][]kubeschedulerconfig.Plugin{
"FilterPlugin": {
{Name: "NodeUnschedulable"},
{Name: "NodeResources"},
{Name: "NodeResourcesFit"},
{Name: "NodeName"},
{Name: "NodePorts"},
{Name: "NodeAffinity"},
Expand Down Expand Up @@ -221,7 +221,7 @@ kind: Policy
expectedPlugins: map[string][]kubeschedulerconfig.Plugin{
"FilterPlugin": {
{Name: "NodeUnschedulable"},
{Name: "NodeResources"},
{Name: "NodeResourcesFit"},
{Name: "NodeName"},
{Name: "NodePorts"},
{Name: "NodeAffinity"},
Expand Down