rename FilterPlugin NodeResources

Signed-off-by: Zou Nengren <zouyee1989@gmail.com>
This commit is contained in:
zouyee 2019-10-20 12:51:16 +08:00
parent e1685b5b59
commit 04340eaa34
6 changed files with 38 additions and 38 deletions

View File

@ -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"},
@ -104,7 +104,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
"FilterPlugin": {
{Name: "NodeUnschedulable"},
{Name: "NodeAffinity"},
{Name: "NodeResources"},
{Name: "NodeResourcesFit"},
{Name: "VolumeRestrictions"},
{Name: "TaintToleration"},
},
@ -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"},
},
@ -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"},
@ -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"},
@ -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"},
@ -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"},
@ -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"},
@ -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"},
@ -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"},
@ -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"},
@ -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"},
@ -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"},
@ -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"},
@ -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",

View File

@ -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,
@ -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)
@ -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,

View File

@ -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",
@ -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 = [

View File

@ -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))
@ -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
}

View File

@ -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 {
@ -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)
@ -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)
@ -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)

View File

@ -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"},
@ -221,7 +221,7 @@ kind: Policy
expectedPlugins: map[string][]kubeschedulerconfig.Plugin{
"FilterPlugin": {
{Name: "NodeUnschedulable"},
{Name: "NodeResources"},
{Name: "NodeResourcesFit"},
{Name: "NodeName"},
{Name: "NodePorts"},
{Name: "NodeAffinity"},