diff --git a/pkg/scheduler/core/generic_scheduler.go b/pkg/scheduler/core/generic_scheduler.go index aa5f598f1fb..1fe3b913d76 100644 --- a/pkg/scheduler/core/generic_scheduler.go +++ b/pkg/scheduler/core/generic_scheduler.go @@ -195,9 +195,9 @@ func (g *genericScheduler) Schedule(pod *v1.Pod, pluginContext *framework.Plugin } // Run "prefilter" plugins. - prefilterStatus := g.framework.RunPrefilterPlugins(pluginContext, pod) - if !prefilterStatus.IsSuccess() { - return result, prefilterStatus.AsError() + preFilterStatus := g.framework.RunPreFilterPlugins(pluginContext, pod) + if !preFilterStatus.IsSuccess() { + return result, preFilterStatus.AsError() } numNodes := g.cache.NodeTree().NumNodes() diff --git a/pkg/scheduler/framework/plugins/examples/multipoint/multipoint.go b/pkg/scheduler/framework/plugins/examples/multipoint/multipoint.go index c927c34ccc7..d33f221f412 100644 --- a/pkg/scheduler/framework/plugins/examples/multipoint/multipoint.go +++ b/pkg/scheduler/framework/plugins/examples/multipoint/multipoint.go @@ -17,7 +17,7 @@ limitations under the License. package multipoint import ( - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1" ) @@ -27,7 +27,7 @@ import ( type CommunicatingPlugin struct{} var _ = framework.ReservePlugin(CommunicatingPlugin{}) -var _ = framework.PrebindPlugin(CommunicatingPlugin{}) +var _ = framework.PreBindPlugin(CommunicatingPlugin{}) // Name is the name of the plug used in Registry and configurations. const Name = "multipoint-communicating-plugin" @@ -50,8 +50,8 @@ func (mc CommunicatingPlugin) Reserve(pc *framework.PluginContext, pod *v1.Pod, return nil } -// Prebind is the functions invoked by the framework at "prebind" extension point. -func (mc CommunicatingPlugin) Prebind(pc *framework.PluginContext, pod *v1.Pod, nodeName string) *framework.Status { +// PreBind is the functions invoked by the framework at "prebind" extension point. +func (mc CommunicatingPlugin) PreBind(pc *framework.PluginContext, pod *v1.Pod, nodeName string) *framework.Status { if pod == nil { return framework.NewStatus(framework.Error, "pod cannot be nil") } diff --git a/pkg/scheduler/framework/plugins/examples/prebind/prebind.go b/pkg/scheduler/framework/plugins/examples/prebind/prebind.go index 71b58127275..723bc4946f9 100644 --- a/pkg/scheduler/framework/plugins/examples/prebind/prebind.go +++ b/pkg/scheduler/framework/plugins/examples/prebind/prebind.go @@ -19,27 +19,27 @@ package prebind import ( "fmt" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1" ) -// StatelessPrebindExample is an example of a simple plugin that has no state +// StatelessPreBindExample is an example of a simple plugin that has no state // 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. const Name = "stateless-prebind-plugin-example" // Name returns name of the plugin. It is used in logs, etc. -func (sr StatelessPrebindExample) Name() string { +func (sr StatelessPreBindExample) Name() string { return Name } -// Prebind is the functions invoked by the framework at "prebind" extension point. -func (sr StatelessPrebindExample) Prebind(pc *framework.PluginContext, pod *v1.Pod, nodeName string) *framework.Status { +// PreBind is the functions invoked by the framework at "prebind" extension point. +func (sr StatelessPreBindExample) PreBind(pc *framework.PluginContext, pod *v1.Pod, nodeName string) *framework.Status { if pod == nil { return framework.NewStatus(framework.Error, fmt.Sprintf("pod cannot be nil")) } @@ -51,5 +51,5 @@ func (sr StatelessPrebindExample) Prebind(pc *framework.PluginContext, pod *v1.P // New initializes a new plugin and returns it. func New(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) { - return &StatelessPrebindExample{}, nil + return &StatelessPreBindExample{}, nil } diff --git a/pkg/scheduler/framework/plugins/examples/stateful/stateful.go b/pkg/scheduler/framework/plugins/examples/stateful/stateful.go index 30b2104a473..e1bce213138 100644 --- a/pkg/scheduler/framework/plugins/examples/stateful/stateful.go +++ b/pkg/scheduler/framework/plugins/examples/stateful/stateful.go @@ -20,7 +20,7 @@ import ( "fmt" "sync" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/klog" framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1" @@ -36,7 +36,7 @@ type MultipointExample struct { } var _ = framework.ReservePlugin(&MultipointExample{}) -var _ = framework.PrebindPlugin(&MultipointExample{}) +var _ = framework.PreBindPlugin(&MultipointExample{}) // Name is the name of the plug used in Registry and configurations. const Name = "multipoint-plugin-example" @@ -53,9 +53,9 @@ func (mp *MultipointExample) Reserve(pc *framework.PluginContext, pod *v1.Pod, n return nil } -// Prebind is the functions invoked by the framework at "prebind" extension point. -func (mp *MultipointExample) Prebind(pc *framework.PluginContext, pod *v1.Pod, nodeName string) *framework.Status { - // Prebind could be called concurrently for different pods. +// PreBind is the functions invoked by the framework at "prebind" extension point. +func (mp *MultipointExample) PreBind(pc *framework.PluginContext, pod *v1.Pod, nodeName string) *framework.Status { + // PreBind could be called concurrently for different pods. mp.mu.Lock() defer mp.mu.Unlock() mp.numRuns++ diff --git a/pkg/scheduler/framework/v1alpha1/framework.go b/pkg/scheduler/framework/v1alpha1/framework.go index 252d02e0cdc..893567b58a2 100644 --- a/pkg/scheduler/framework/v1alpha1/framework.go +++ b/pkg/scheduler/framework/v1alpha1/framework.go @@ -39,15 +39,15 @@ type framework struct { waitingPods *waitingPodsMap pluginNameToWeightMap map[string]int queueSortPlugins []QueueSortPlugin - prefilterPlugins []PrefilterPlugin + preFilterPlugins []PreFilterPlugin filterPlugins []FilterPlugin postFilterPlugins []PostFilterPlugin scorePlugins []ScorePlugin scoreWithNormalizePlugins []ScoreWithNormalizePlugin reservePlugins []ReservePlugin - prebindPlugins []PrebindPlugin + preBindPlugins []PreBindPlugin bindPlugins []BindPlugin - postbindPlugins []PostbindPlugin + postBindPlugins []PostBindPlugin unreservePlugins []UnreservePlugin permitPlugins []PermitPlugin } @@ -105,11 +105,11 @@ func NewFramework(r Registry, plugins *config.Plugins, args []config.PluginConfi if plugins.PreFilter != nil { for _, pf := range plugins.PreFilter.Enabled { if pg, ok := pluginsMap[pf.Name]; ok { - p, ok := pg.(PrefilterPlugin) + p, ok := pg.(PreFilterPlugin) if !ok { return nil, fmt.Errorf("plugin %q does not extend prefilter plugin", pf.Name) } - f.prefilterPlugins = append(f.prefilterPlugins, p) + f.preFilterPlugins = append(f.preFilterPlugins, p) } else { return nil, fmt.Errorf("prefilter plugin %q does not exist", pf.Name) } @@ -186,11 +186,11 @@ func NewFramework(r Registry, plugins *config.Plugins, args []config.PluginConfi if plugins.PreBind != nil { for _, pb := range plugins.PreBind.Enabled { if pg, ok := pluginsMap[pb.Name]; ok { - p, ok := pg.(PrebindPlugin) + p, ok := pg.(PreBindPlugin) if !ok { return nil, fmt.Errorf("plugin %q does not extend prebind plugin", pb.Name) } - f.prebindPlugins = append(f.prebindPlugins, p) + f.preBindPlugins = append(f.preBindPlugins, p) } else { return nil, fmt.Errorf("prebind plugin %q does not exist", pb.Name) } @@ -214,11 +214,11 @@ func NewFramework(r Registry, plugins *config.Plugins, args []config.PluginConfi if plugins.PostBind != nil { for _, pb := range plugins.PostBind.Enabled { if pg, ok := pluginsMap[pb.Name]; ok { - p, ok := pg.(PostbindPlugin) + p, ok := pg.(PostBindPlugin) if !ok { return nil, fmt.Errorf("plugin %q does not extend postbind plugin", pb.Name) } - f.postbindPlugins = append(f.postbindPlugins, p) + f.postBindPlugins = append(f.postBindPlugins, p) } else { return nil, fmt.Errorf("postbind plugin %q does not exist", pb.Name) } @@ -283,14 +283,14 @@ func (f *framework) QueueSortFunc() LessFunc { return f.queueSortPlugins[0].Less } -// RunPrefilterPlugins runs the set of configured prefilter plugins. It returns +// RunPreFilterPlugins runs the set of configured PreFilter plugins. It returns // *Status and its code is set to non-success if any of the plugins returns // anything but Success. If a non-success status is returned, then the scheduling // cycle is aborted. -func (f *framework) RunPrefilterPlugins( +func (f *framework) RunPreFilterPlugins( pc *PluginContext, pod *v1.Pod) *Status { - for _, pl := range f.prefilterPlugins { - status := pl.Prefilter(pc, pod) + for _, pl := range f.preFilterPlugins { + status := pl.PreFilter(pc, pod) if !status.IsSuccess() { if status.Code() == Unschedulable { msg := fmt.Sprintf("rejected by %q at prefilter: %v", pl.Name(), status.Message()) @@ -425,13 +425,13 @@ func (f *framework) RunScorePlugins(pc *PluginContext, pod *v1.Pod, nodes []*v1. return pluginToNodeScores, nil } -// RunPrebindPlugins runs the set of configured prebind plugins. It returns a +// RunPreBindPlugins runs the set of configured prebind plugins. It returns a // failure (bool) if any of the plugins returns an error. It also returns an // error containing the rejection message or the error occurred in the plugin. -func (f *framework) RunPrebindPlugins( +func (f *framework) RunPreBindPlugins( pc *PluginContext, pod *v1.Pod, nodeName string) *Status { - for _, pl := range f.prebindPlugins { - status := pl.Prebind(pc, pod, nodeName) + for _, pl := range f.preBindPlugins { + status := pl.PreBind(pc, pod, nodeName) if !status.IsSuccess() { if status.Code() == Unschedulable { msg := fmt.Sprintf("rejected by %q at prebind: %v", pl.Name(), status.Message()) @@ -467,11 +467,11 @@ func (f *framework) RunBindPlugins(pc *PluginContext, pod *v1.Pod, nodeName stri return status } -// RunPostbindPlugins runs the set of configured postbind plugins. -func (f *framework) RunPostbindPlugins( +// RunPostBindPlugins runs the set of configured postbind plugins. +func (f *framework) RunPostBindPlugins( pc *PluginContext, pod *v1.Pod, nodeName string) { - for _, pl := range f.postbindPlugins { - pl.Postbind(pc, pod, nodeName) + for _, pl := range f.postBindPlugins { + pl.PostBind(pc, pod, nodeName) } } diff --git a/pkg/scheduler/framework/v1alpha1/interface.go b/pkg/scheduler/framework/v1alpha1/interface.go index 70c59490c36..ba5b8a77895 100644 --- a/pkg/scheduler/framework/v1alpha1/interface.go +++ b/pkg/scheduler/framework/v1alpha1/interface.go @@ -152,13 +152,13 @@ type QueueSortPlugin interface { Less(*PodInfo, *PodInfo) bool } -// PrefilterPlugin is an interface that must be implemented by "prefilter" plugins. +// PreFilterPlugin is an interface that must be implemented by "prefilter" plugins. // These plugins are called at the beginning of the scheduling cycle. -type PrefilterPlugin interface { +type PreFilterPlugin interface { Plugin - // Prefilter is called at the beginning of the scheduling cycle. All prefilter + // PreFilter is called at the beginning of the scheduling cycle. All PreFilter // plugins must return success or the pod will be rejected. - Prefilter(pc *PluginContext, p *v1.Pod) *Status + PreFilter(pc *PluginContext, p *v1.Pod) *Status } // FilterPlugin is an interface for Filter plugins. These plugins are called at the @@ -225,24 +225,24 @@ type ReservePlugin interface { Reserve(pc *PluginContext, p *v1.Pod, nodeName string) *Status } -// PrebindPlugin is an interface that must be implemented by "prebind" plugins. +// PreBindPlugin is an interface that must be implemented by "prebind" plugins. // These plugins are called before a pod being scheduled. -type PrebindPlugin interface { +type PreBindPlugin interface { Plugin - // Prebind is called before binding a pod. All prebind plugins must return + // PreBind is called before binding a pod. All prebind plugins must return // success or the pod will be rejected and won't be sent for binding. - Prebind(pc *PluginContext, p *v1.Pod, nodeName string) *Status + PreBind(pc *PluginContext, p *v1.Pod, nodeName string) *Status } -// PostbindPlugin is an interface that must be implemented by "postbind" plugins. +// PostBindPlugin is an interface that must be implemented by "postbind" plugins. // These plugins are called after a pod is successfully bound to a node. -type PostbindPlugin interface { +type PostBindPlugin interface { Plugin - // Postbind is called after a pod is successfully bound. These plugins are + // PostBind is called after a pod is successfully bound. These plugins are // informational. A common application of this extension point is for cleaning // up. If a plugin needs to clean-up its state after a pod is scheduled and - // bound, Postbind is the extension point that it should register. - Postbind(pc *PluginContext, p *v1.Pod, nodeName string) + // bound, PostBind is the extension point that it should register. + PostBind(pc *PluginContext, p *v1.Pod, nodeName string) } // UnreservePlugin is an interface for Unreserve plugins. This is an informational @@ -289,11 +289,11 @@ type Framework interface { // QueueSortFunc returns the function to sort pods in scheduling queue QueueSortFunc() LessFunc - // RunPrefilterPlugins runs the set of configured prefilter plugins. It returns + // RunPreFilterPlugins runs the set of configured prefilter plugins. It returns // *Status and its code is set to non-success if any of the plugins returns // anything but Success. If a non-success status is returned, then the scheduling // cycle is aborted. - RunPrefilterPlugins(pc *PluginContext, pod *v1.Pod) *Status + RunPreFilterPlugins(pc *PluginContext, pod *v1.Pod) *Status // RunFilterPlugins runs the set of configured filter plugins for pod on the // given host. If any of these plugins returns any status other than "Success", @@ -311,15 +311,15 @@ type Framework interface { // a non-success status. RunScorePlugins(pc *PluginContext, pod *v1.Pod, nodes []*v1.Node) (PluginToNodeScores, *Status) - // RunPrebindPlugins runs the set of configured prebind plugins. It returns + // RunPreBindPlugins runs the set of configured prebind plugins. It returns // *Status and its code is set to non-success if any of the plugins returns // anything but Success. If the Status code is "Unschedulable", it is // considered as a scheduling check failure, otherwise, it is considered as an // internal error. In either case the pod is not going to be bound. - RunPrebindPlugins(pc *PluginContext, pod *v1.Pod, nodeName string) *Status + RunPreBindPlugins(pc *PluginContext, pod *v1.Pod, nodeName string) *Status - // RunPostbindPlugins runs the set of configured postbind plugins. - RunPostbindPlugins(pc *PluginContext, pod *v1.Pod, nodeName string) + // RunPostBindPlugins runs the set of configured postbind plugins. + RunPostBindPlugins(pc *PluginContext, pod *v1.Pod, nodeName string) // RunReservePlugins runs the set of configured reserve plugins. If any of these // plugins returns an error, it does not continue running the remaining ones and diff --git a/pkg/scheduler/internal/queue/scheduling_queue_test.go b/pkg/scheduler/internal/queue/scheduling_queue_test.go index 1bdce2c517c..475dffe4bca 100644 --- a/pkg/scheduler/internal/queue/scheduling_queue_test.go +++ b/pkg/scheduler/internal/queue/scheduling_queue_test.go @@ -167,7 +167,7 @@ func (*fakeFramework) NodeInfoSnapshot() *internalcache.NodeInfoSnapshot { return nil } -func (*fakeFramework) RunPrefilterPlugins(pc *framework.PluginContext, pod *v1.Pod) *framework.Status { +func (*fakeFramework) RunPreFilterPlugins(pc *framework.PluginContext, pod *v1.Pod) *framework.Status { return nil } @@ -179,7 +179,7 @@ func (*fakeFramework) RunScorePlugins(pc *framework.PluginContext, pod *v1.Pod, return nil, nil } -func (*fakeFramework) RunPrebindPlugins(pc *framework.PluginContext, pod *v1.Pod, nodeName string) *framework.Status { +func (*fakeFramework) RunPreBindPlugins(pc *framework.PluginContext, pod *v1.Pod, nodeName string) *framework.Status { return nil } @@ -187,7 +187,7 @@ func (*fakeFramework) RunBindPlugins(pc *framework.PluginContext, pod *v1.Pod, n return nil } -func (*fakeFramework) RunPostbindPlugins(pc *framework.PluginContext, pod *v1.Pod, nodeName string) {} +func (*fakeFramework) RunPostBindPlugins(pc *framework.PluginContext, pod *v1.Pod, nodeName string) {} func (*fakeFramework) RunPostFilterPlugins(pc *framework.PluginContext, pod *v1.Pod, nodes []*v1.Node, filteredNodesStatuses framework.NodeToStatusMap) *framework.Status { return nil diff --git a/pkg/scheduler/scheduler.go b/pkg/scheduler/scheduler.go index e284a4523cc..531d1d1546b 100644 --- a/pkg/scheduler/scheduler.go +++ b/pkg/scheduler/scheduler.go @@ -632,10 +632,10 @@ func (sched *Scheduler) scheduleOne() { } // Run "prebind" plugins. - prebindStatus := fwk.RunPrebindPlugins(pluginContext, assumedPod, scheduleResult.SuggestedHost) - if !prebindStatus.IsSuccess() { + preBindStatus := fwk.RunPreBindPlugins(pluginContext, assumedPod, scheduleResult.SuggestedHost) + if !preBindStatus.IsSuccess() { var reason string - if prebindStatus.Code() == framework.Unschedulable { + if preBindStatus.Code() == framework.Unschedulable { metrics.PodScheduleFailures.Inc() reason = v1.PodReasonUnschedulable } else { @@ -647,7 +647,7 @@ func (sched *Scheduler) scheduleOne() { } // trigger un-reserve plugins to clean up state associated with the reserved Pod fwk.RunUnreservePlugins(pluginContext, assumedPod, scheduleResult.SuggestedHost) - sched.recordSchedulingFailure(assumedPod, prebindStatus.AsError(), reason, prebindStatus.Message()) + sched.recordSchedulingFailure(assumedPod, preBindStatus.AsError(), reason, preBindStatus.Message()) return } @@ -670,7 +670,7 @@ func (sched *Scheduler) scheduleOne() { metrics.PodScheduleSuccesses.Inc() // Run "postbind" plugins. - fwk.RunPostbindPlugins(pluginContext, assumedPod, scheduleResult.SuggestedHost) + fwk.RunPostBindPlugins(pluginContext, assumedPod, scheduleResult.SuggestedHost) } }() } diff --git a/test/integration/scheduler/framework_test.go b/test/integration/scheduler/framework_test.go index 37ec42b9e24..735ddce10c4 100644 --- a/test/integration/scheduler/framework_test.go +++ b/test/integration/scheduler/framework_test.go @@ -31,10 +31,10 @@ import ( framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1" ) -type PrefilterPlugin struct { - numPrefilterCalled int - failPrefilter bool - rejectPrefilter bool +type PreFilterPlugin struct { + numPreFilterCalled int + failPreFilter bool + rejectPreFilter bool } type ScorePlugin struct { @@ -63,10 +63,10 @@ type PostFilterPlugin struct { failPostFilter bool } -type PrebindPlugin struct { - numPrebindCalled int - failPrebind bool - rejectPrebind bool +type PreBindPlugin struct { + numPreBindCalled int + failPreBind bool + rejectPreBind bool } type BindPlugin struct { @@ -77,9 +77,9 @@ type BindPlugin struct { pluginInvokeEventChan chan pluginInvokeEvent } -type PostbindPlugin struct { +type PostBindPlugin struct { name string - numPostbindCalled int + numPostBindCalled int pluginInvokeEventChan chan pluginInvokeEvent } @@ -107,22 +107,22 @@ const ( filterPluginName = "filter-plugin" postFilterPluginName = "postfilter-plugin" reservePluginName = "reserve-plugin" - prebindPluginName = "prebind-plugin" + preBindPluginName = "prebind-plugin" unreservePluginName = "unreserve-plugin" - postbindPluginName = "postbind-plugin" + postBindPluginName = "postbind-plugin" permitPluginName = "permit-plugin" ) -var _ = framework.PrefilterPlugin(&PrefilterPlugin{}) +var _ = framework.PreFilterPlugin(&PreFilterPlugin{}) var _ = framework.ScorePlugin(&ScorePlugin{}) var _ = framework.FilterPlugin(&FilterPlugin{}) var _ = framework.ScorePlugin(&ScorePlugin{}) var _ = framework.ScoreWithNormalizePlugin(&ScoreWithNormalizePlugin{}) var _ = framework.ReservePlugin(&ReservePlugin{}) var _ = framework.PostFilterPlugin(&PostFilterPlugin{}) -var _ = framework.PrebindPlugin(&PrebindPlugin{}) +var _ = framework.PreBindPlugin(&PreBindPlugin{}) var _ = framework.BindPlugin(&BindPlugin{}) -var _ = framework.PostbindPlugin(&PostbindPlugin{}) +var _ = framework.PostBindPlugin(&PostBindPlugin{}) var _ = framework.UnreservePlugin(&UnreservePlugin{}) var _ = framework.PermitPlugin(&PermitPlugin{}) @@ -249,27 +249,27 @@ func (pfp *PostFilterPlugin) reset() { } // Name returns name of the plugin. -func (pp *PrebindPlugin) Name() string { - return prebindPluginName +func (pp *PreBindPlugin) Name() string { + return preBindPluginName } -// Prebind is a test function that returns (true, nil) or errors for testing. -func (pp *PrebindPlugin) Prebind(pc *framework.PluginContext, pod *v1.Pod, nodeName string) *framework.Status { - pp.numPrebindCalled++ - if pp.failPrebind { +// PreBind is a test function that returns (true, nil) or errors for testing. +func (pp *PreBindPlugin) PreBind(pc *framework.PluginContext, pod *v1.Pod, nodeName string) *framework.Status { + pp.numPreBindCalled++ + if pp.failPreBind { return framework.NewStatus(framework.Error, fmt.Sprintf("injecting failure for pod %v", pod.Name)) } - if pp.rejectPrebind { + if pp.rejectPreBind { return framework.NewStatus(framework.Unschedulable, fmt.Sprintf("reject pod %v", pod.Name)) } return nil } // reset used to reset prebind plugin. -func (pp *PrebindPlugin) reset() { - pp.numPrebindCalled = 0 - pp.failPrebind = false - pp.rejectPrebind = false +func (pp *PreBindPlugin) reset() { + pp.numPreBindCalled = 0 + pp.failPreBind = false + pp.rejectPreBind = false } const bindPluginAnnotation = "bindPluginName" @@ -303,45 +303,45 @@ func (bp *BindPlugin) reset() { } // Name returns name of the plugin. -func (pp *PostbindPlugin) Name() string { +func (pp *PostBindPlugin) Name() string { return pp.name } -// Postbind is a test function, which counts the number of times called. -func (pp *PostbindPlugin) Postbind(pc *framework.PluginContext, pod *v1.Pod, nodeName string) { - pp.numPostbindCalled++ +// PostBind is a test function, which counts the number of times called. +func (pp *PostBindPlugin) PostBind(pc *framework.PluginContext, pod *v1.Pod, nodeName string) { + pp.numPostBindCalled++ if pp.pluginInvokeEventChan != nil { - pp.pluginInvokeEventChan <- pluginInvokeEvent{pluginName: pp.Name(), val: pp.numPostbindCalled} + pp.pluginInvokeEventChan <- pluginInvokeEvent{pluginName: pp.Name(), val: pp.numPostBindCalled} } } // reset used to reset postbind plugin. -func (pp *PostbindPlugin) reset() { - pp.numPostbindCalled = 0 +func (pp *PostBindPlugin) reset() { + pp.numPostBindCalled = 0 } // Name returns name of the plugin. -func (pp *PrefilterPlugin) Name() string { +func (pp *PreFilterPlugin) Name() string { return prefilterPluginName } -// Prefilter is a test function that returns (true, nil) or errors for testing. -func (pp *PrefilterPlugin) Prefilter(pc *framework.PluginContext, pod *v1.Pod) *framework.Status { - pp.numPrefilterCalled++ - if pp.failPrefilter { +// PreFilter is a test function that returns (true, nil) or errors for testing. +func (pp *PreFilterPlugin) PreFilter(pc *framework.PluginContext, pod *v1.Pod) *framework.Status { + pp.numPreFilterCalled++ + if pp.failPreFilter { return framework.NewStatus(framework.Error, fmt.Sprintf("injecting failure for pod %v", pod.Name)) } - if pp.rejectPrefilter { + if pp.rejectPreFilter { return framework.NewStatus(framework.Unschedulable, fmt.Sprintf("reject pod %v", pod.Name)) } return nil } // reset used to reset prefilter plugin. -func (pp *PrefilterPlugin) reset() { - pp.numPrefilterCalled = 0 - pp.failPrefilter = false - pp.rejectPrefilter = false +func (pp *PreFilterPlugin) reset() { + pp.numPreFilterCalled = 0 + pp.failPreFilter = false + pp.rejectPreFilter = false } // Name returns name of the plugin. @@ -426,11 +426,11 @@ func newPermitPlugin(permitPlugin *PermitPlugin) framework.PluginFactory { } } -// TestPrefilterPlugin tests invocation of prefilter plugins. -func TestPrefilterPlugin(t *testing.T) { +// TestPreFilterPlugin tests invocation of prefilter plugins. +func TestPreFilterPlugin(t *testing.T) { // Create a plugin registry for testing. Register only a pre-filter plugin. - prefilterPlugin := &PrefilterPlugin{} - registry := framework.Registry{prefilterPluginName: newPlugin(prefilterPlugin)} + preFilterPlugin := &PreFilterPlugin{} + registry := framework.Registry{prefilterPluginName: newPlugin(preFilterPlugin)} // Setup initial prefilter plugin for testing. plugins := &schedulerconfig.Plugins{ @@ -478,8 +478,8 @@ func TestPrefilterPlugin(t *testing.T) { } for i, test := range tests { - prefilterPlugin.failPrefilter = test.fail - prefilterPlugin.rejectPrefilter = test.reject + preFilterPlugin.failPreFilter = test.fail + preFilterPlugin.rejectPreFilter = test.reject // Create a best effort pod. pod, err := createPausePod(cs, initPausePod(cs, &pausePodConfig{Name: "test-pod", Namespace: context.ns.Name})) @@ -497,11 +497,11 @@ func TestPrefilterPlugin(t *testing.T) { } } - if prefilterPlugin.numPrefilterCalled == 0 { + if preFilterPlugin.numPreFilterCalled == 0 { t.Errorf("Expected the prefilter plugin to be called.") } - prefilterPlugin.reset() + preFilterPlugin.reset() cleanupPods(cs, t, []*v1.Pod{pod}) } } @@ -667,15 +667,15 @@ func TestReservePlugin(t *testing.T) { // TestPrebindPlugin tests invocation of prebind plugins. func TestPrebindPlugin(t *testing.T) { // Create a plugin registry for testing. Register only a prebind plugin. - prebindPlugin := &PrebindPlugin{} - registry := framework.Registry{prebindPluginName: newPlugin(prebindPlugin)} + preBindPlugin := &PreBindPlugin{} + registry := framework.Registry{preBindPluginName: newPlugin(preBindPlugin)} // Setup initial prebind plugin for testing. plugins := &schedulerconfig.Plugins{ PreBind: &schedulerconfig.PluginSet{ Enabled: []schedulerconfig.Plugin{ { - Name: prebindPluginName, + Name: preBindPluginName, }, }, }, @@ -683,7 +683,7 @@ func TestPrebindPlugin(t *testing.T) { // Set reserve prebind config for testing preBindPluginConfig := []schedulerconfig.PluginConfig{ { - Name: prebindPluginName, + Name: preBindPluginName, Args: runtime.Unknown{}, }, } @@ -723,8 +723,8 @@ func TestPrebindPlugin(t *testing.T) { } for i, test := range tests { - prebindPlugin.failPrebind = test.fail - prebindPlugin.rejectPrebind = test.reject + preBindPlugin.failPreBind = test.fail + preBindPlugin.rejectPreBind = test.reject // Create a best effort pod. pod, err := createPausePod(cs, initPausePod(cs, &pausePodConfig{Name: "test-pod", Namespace: context.ns.Name})) @@ -748,11 +748,11 @@ func TestPrebindPlugin(t *testing.T) { } } - if prebindPlugin.numPrebindCalled == 0 { + if preBindPlugin.numPreBindCalled == 0 { t.Errorf("Expected the prebind plugin to be called.") } - prebindPlugin.reset() + preBindPlugin.reset() cleanupPods(cs, t, []*v1.Pod{pod}) } } @@ -760,11 +760,11 @@ func TestPrebindPlugin(t *testing.T) { // TestUnreservePlugin tests invocation of un-reserve plugin func TestUnreservePlugin(t *testing.T) { // TODO: register more plugin which would trigger un-reserve plugin - prebindPlugin := &PrebindPlugin{} + preBindPlugin := &PreBindPlugin{} unreservePlugin := &UnreservePlugin{name: unreservePluginName} registry := framework.Registry{ unreservePluginName: newPlugin(unreservePlugin), - prebindPluginName: newPlugin(prebindPlugin), + preBindPluginName: newPlugin(preBindPlugin), } // Setup initial unreserve and prebind plugin for testing. @@ -779,7 +779,7 @@ func TestUnreservePlugin(t *testing.T) { PreBind: &schedulerconfig.PluginSet{ Enabled: []schedulerconfig.Plugin{ { - Name: prebindPluginName, + Name: preBindPluginName, }, }, }, @@ -791,7 +791,7 @@ func TestUnreservePlugin(t *testing.T) { Args: runtime.Unknown{}, }, { - Name: prebindPluginName, + Name: preBindPluginName, Args: runtime.Unknown{}, }, } @@ -810,30 +810,30 @@ func TestUnreservePlugin(t *testing.T) { } tests := []struct { - prebindFail bool - prebindReject bool + preBindFail bool + preBindReject bool }{ { - prebindFail: false, - prebindReject: false, + preBindFail: false, + preBindReject: false, }, { - prebindFail: true, - prebindReject: false, + preBindFail: true, + preBindReject: false, }, { - prebindFail: false, - prebindReject: true, + preBindFail: false, + preBindReject: true, }, { - prebindFail: true, - prebindReject: true, + preBindFail: true, + preBindReject: true, }, } for i, test := range tests { - prebindPlugin.failPrebind = test.prebindFail - prebindPlugin.rejectPrebind = test.prebindReject + preBindPlugin.failPreBind = test.preBindFail + preBindPlugin.rejectPreBind = test.preBindReject // Create a best effort pod. pod, err := createPausePod(cs, @@ -842,20 +842,20 @@ func TestUnreservePlugin(t *testing.T) { t.Errorf("Error while creating a test pod: %v", err) } - if test.prebindFail { + if test.preBindFail { if err = wait.Poll(10*time.Millisecond, 30*time.Second, podSchedulingError(cs, pod.Namespace, pod.Name)); err != nil { t.Errorf("test #%v: Expected a scheduling error, but didn't get it. error: %v", i, err) } - if unreservePlugin.numUnreserveCalled == 0 || unreservePlugin.numUnreserveCalled != prebindPlugin.numPrebindCalled { - t.Errorf("test #%v: Expected the unreserve plugin to be called %d times, was called %d times.", i, prebindPlugin.numPrebindCalled, unreservePlugin.numUnreserveCalled) + if unreservePlugin.numUnreserveCalled == 0 || unreservePlugin.numUnreserveCalled != preBindPlugin.numPreBindCalled { + t.Errorf("test #%v: Expected the unreserve plugin to be called %d times, was called %d times.", i, preBindPlugin.numPreBindCalled, unreservePlugin.numUnreserveCalled) } } else { - if test.prebindReject { + if test.preBindReject { if err = waitForPodUnschedulable(cs, pod); err != nil { t.Errorf("test #%v: Didn't expected the pod to be scheduled. error: %v", i, err) } if unreservePlugin.numUnreserveCalled == 0 { - t.Errorf("test #%v: Expected the unreserve plugin to be called %d times, was called %d times.", i, prebindPlugin.numPrebindCalled, unreservePlugin.numUnreserveCalled) + t.Errorf("test #%v: Expected the unreserve plugin to be called %d times, was called %d times.", i, preBindPlugin.numPreBindCalled, unreservePlugin.numUnreserveCalled) } } else { if err = waitForPodToSchedule(cs, pod); err != nil { @@ -868,7 +868,7 @@ func TestUnreservePlugin(t *testing.T) { } unreservePlugin.reset() - prebindPlugin.reset() + preBindPlugin.reset() cleanupPods(cs, t, []*v1.Pod{pod}) } } @@ -884,7 +884,7 @@ func TestBindPlugin(t *testing.T) { bindPlugin1 := &BindPlugin{PluginName: "bind-plugin-1", client: testContext.clientSet} bindPlugin2 := &BindPlugin{PluginName: "bind-plugin-2", client: testContext.clientSet} unreservePlugin := &UnreservePlugin{name: "mock-unreserve-plugin"} - postbindPlugin := &PostbindPlugin{name: "mock-post-bind-plugin"} + postBindPlugin := &PostBindPlugin{name: "mock-post-bind-plugin"} // Create a plugin registry for testing. Register an unreserve, a bind plugin and a postBind plugin. registry := framework.Registry{ unreservePlugin.Name(): func(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) { @@ -896,8 +896,8 @@ func TestBindPlugin(t *testing.T) { bindPlugin2.Name(): func(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) { return bindPlugin2, nil }, - postbindPlugin.Name(): func(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) { - return postbindPlugin, nil + postBindPlugin.Name(): func(_ *runtime.Unknown, _ framework.FrameworkHandle) (framework.Plugin, error) { + return postBindPlugin, nil }, } @@ -910,7 +910,7 @@ func TestBindPlugin(t *testing.T) { Enabled: []schedulerconfig.Plugin{{Name: bindPlugin1.Name()}, {Name: bindPlugin2.Name()}}, }, PostBind: &schedulerconfig.PluginSet{ - Enabled: []schedulerconfig.Plugin{{Name: postbindPlugin.Name()}}, + Enabled: []schedulerconfig.Plugin{{Name: postBindPlugin.Name()}}, }, } // Set reserve and bind config for testing @@ -928,7 +928,7 @@ func TestBindPlugin(t *testing.T) { Args: runtime.Unknown{}, }, { - Name: postbindPlugin.Name(), + Name: postBindPlugin.Name(), Args: runtime.Unknown{}, }, } @@ -956,21 +956,21 @@ func TestBindPlugin(t *testing.T) { { bindPluginStatuses: []*framework.Status{framework.NewStatus(framework.Skip, ""), framework.NewStatus(framework.Skip, "")}, expectBoundByScheduler: true, - expectInvokeEvents: []pluginInvokeEvent{{pluginName: bindPlugin1.Name(), val: 1}, {pluginName: bindPlugin2.Name(), val: 1}, {pluginName: postbindPlugin.Name(), val: 1}}, + expectInvokeEvents: []pluginInvokeEvent{{pluginName: bindPlugin1.Name(), val: 1}, {pluginName: bindPlugin2.Name(), val: 1}, {pluginName: postBindPlugin.Name(), val: 1}}, }, // bindplugin2 succeeded to bind the pod { bindPluginStatuses: []*framework.Status{framework.NewStatus(framework.Skip, ""), framework.NewStatus(framework.Success, "")}, expectBoundByPlugin: true, expectBindPluginName: bindPlugin2.Name(), - expectInvokeEvents: []pluginInvokeEvent{{pluginName: bindPlugin1.Name(), val: 1}, {pluginName: bindPlugin2.Name(), val: 1}, {pluginName: postbindPlugin.Name(), val: 1}}, + expectInvokeEvents: []pluginInvokeEvent{{pluginName: bindPlugin1.Name(), val: 1}, {pluginName: bindPlugin2.Name(), val: 1}, {pluginName: postBindPlugin.Name(), val: 1}}, }, // bindplugin1 succeeded to bind the pod { bindPluginStatuses: []*framework.Status{framework.NewStatus(framework.Success, ""), framework.NewStatus(framework.Success, "")}, expectBoundByPlugin: true, expectBindPluginName: bindPlugin1.Name(), - expectInvokeEvents: []pluginInvokeEvent{{pluginName: bindPlugin1.Name(), val: 1}, {pluginName: postbindPlugin.Name(), val: 1}}, + expectInvokeEvents: []pluginInvokeEvent{{pluginName: bindPlugin1.Name(), val: 1}, {pluginName: postBindPlugin.Name(), val: 1}}, }, // bind plugin fails to bind the pod { @@ -988,7 +988,7 @@ func TestBindPlugin(t *testing.T) { bindPlugin1.pluginInvokeEventChan = pluginInvokeEventChan bindPlugin2.pluginInvokeEventChan = pluginInvokeEventChan unreservePlugin.pluginInvokeEventChan = pluginInvokeEventChan - postbindPlugin.pluginInvokeEventChan = pluginInvokeEventChan + postBindPlugin.pluginInvokeEventChan = pluginInvokeEventChan // Create a best effort pod. pod, err := createPausePod(cs, @@ -1027,9 +1027,9 @@ func TestBindPlugin(t *testing.T) { } } if err = wait.Poll(10*time.Millisecond, 30*time.Second, func() (done bool, err error) { - return postbindPlugin.numPostbindCalled == 1, nil + return postBindPlugin.numPostBindCalled == 1, nil }); err != nil { - t.Errorf("test #%v: Expected the postbind plugin to be called once, was called %d times.", i, postbindPlugin.numPostbindCalled) + t.Errorf("test #%v: Expected the postbind plugin to be called once, was called %d times.", i, postBindPlugin.numPostBindCalled) } if unreservePlugin.numUnreserveCalled != 0 { t.Errorf("test #%v: Expected the unreserve plugin not to be called, was called %d times.", i, unreservePlugin.numUnreserveCalled) @@ -1039,8 +1039,8 @@ func TestBindPlugin(t *testing.T) { if err = wait.Poll(10*time.Millisecond, 30*time.Second, podSchedulingError(cs, pod.Namespace, pod.Name)); err != nil { t.Errorf("test #%v: Expected a scheduling error, but didn't get it. error: %v", i, err) } - if postbindPlugin.numPostbindCalled > 0 { - t.Errorf("test #%v: Didn't expected the postbind plugin to be called %d times.", i, postbindPlugin.numPostbindCalled) + if postBindPlugin.numPostBindCalled > 0 { + t.Errorf("test #%v: Didn't expected the postbind plugin to be called %d times.", i, postBindPlugin.numPostBindCalled) } } for j := range test.expectInvokeEvents { @@ -1057,7 +1057,7 @@ func TestBindPlugin(t *testing.T) { t.Errorf("test #%v: Waiting for invoke event %d timeout.", i, j) } } - postbindPlugin.reset() + postBindPlugin.reset() bindPlugin1.reset() bindPlugin2.reset() unreservePlugin.reset() @@ -1065,14 +1065,14 @@ func TestBindPlugin(t *testing.T) { } } -// TestPostbindPlugin tests invocation of postbind plugins. -func TestPostbindPlugin(t *testing.T) { +// TestPostBindPlugin tests invocation of postbind plugins. +func TestPostBindPlugin(t *testing.T) { // Create a plugin registry for testing. Register a prebind and a postbind plugin. - prebindPlugin := &PrebindPlugin{} - postbindPlugin := &PostbindPlugin{name: postbindPluginName} + preBindPlugin := &PreBindPlugin{} + postBindPlugin := &PostBindPlugin{name: postBindPluginName} registry := framework.Registry{ - prebindPluginName: newPlugin(prebindPlugin), - postbindPluginName: newPlugin(postbindPlugin), + preBindPluginName: newPlugin(preBindPlugin), + postBindPluginName: newPlugin(postBindPlugin), } // Setup initial prebind and postbind plugin for testing. @@ -1080,14 +1080,14 @@ func TestPostbindPlugin(t *testing.T) { PreBind: &schedulerconfig.PluginSet{ Enabled: []schedulerconfig.Plugin{ { - Name: prebindPluginName, + Name: preBindPluginName, }, }, }, PostBind: &schedulerconfig.PluginSet{ Enabled: []schedulerconfig.Plugin{ { - Name: postbindPluginName, + Name: postBindPluginName, }, }, }, @@ -1095,11 +1095,11 @@ func TestPostbindPlugin(t *testing.T) { // Set reserve prebind and postbind config for testing pluginConfig := []schedulerconfig.PluginConfig{ { - Name: prebindPluginName, + Name: preBindPluginName, Args: runtime.Unknown{}, }, { - Name: postbindPluginName, + Name: postBindPluginName, Args: runtime.Unknown{}, }, } @@ -1118,30 +1118,30 @@ func TestPostbindPlugin(t *testing.T) { } tests := []struct { - prebindFail bool - prebindReject bool + preBindFail bool + preBindReject bool }{ { - prebindFail: false, - prebindReject: false, + preBindFail: false, + preBindReject: false, }, { - prebindFail: true, - prebindReject: false, + preBindFail: true, + preBindReject: false, }, { - prebindFail: false, - prebindReject: true, + preBindFail: false, + preBindReject: true, }, { - prebindFail: true, - prebindReject: true, + preBindFail: true, + preBindReject: true, }, } for i, test := range tests { - prebindPlugin.failPrebind = test.prebindFail - prebindPlugin.rejectPrebind = test.prebindReject + preBindPlugin.failPreBind = test.preBindFail + preBindPlugin.rejectPreBind = test.preBindReject // Create a best effort pod. pod, err := createPausePod(cs, @@ -1150,33 +1150,33 @@ func TestPostbindPlugin(t *testing.T) { t.Errorf("Error while creating a test pod: %v", err) } - if test.prebindFail { + if test.preBindFail { if err = wait.Poll(10*time.Millisecond, 30*time.Second, podSchedulingError(cs, pod.Namespace, pod.Name)); err != nil { t.Errorf("test #%v: Expected a scheduling error, but didn't get it. error: %v", i, err) } - if postbindPlugin.numPostbindCalled > 0 { - t.Errorf("test #%v: Didn't expected the postbind plugin to be called %d times.", i, postbindPlugin.numPostbindCalled) + if postBindPlugin.numPostBindCalled > 0 { + t.Errorf("test #%v: Didn't expected the postbind plugin to be called %d times.", i, postBindPlugin.numPostBindCalled) } } else { - if test.prebindReject { + if test.preBindReject { if err = waitForPodUnschedulable(cs, pod); err != nil { t.Errorf("test #%v: Didn't expected the pod to be scheduled. error: %v", i, err) } - if postbindPlugin.numPostbindCalled > 0 { - t.Errorf("test #%v: Didn't expected the postbind plugin to be called %d times.", i, postbindPlugin.numPostbindCalled) + if postBindPlugin.numPostBindCalled > 0 { + t.Errorf("test #%v: Didn't expected the postbind plugin to be called %d times.", i, postBindPlugin.numPostBindCalled) } } else { if err = waitForPodToSchedule(cs, pod); err != nil { t.Errorf("test #%v: Expected the pod to be scheduled. error: %v", i, err) } - if postbindPlugin.numPostbindCalled == 0 { - t.Errorf("test #%v: Expected the postbind plugin to be called, was called %d times.", i, postbindPlugin.numPostbindCalled) + if postBindPlugin.numPostBindCalled == 0 { + t.Errorf("test #%v: Expected the postbind plugin to be called, was called %d times.", i, postBindPlugin.numPostBindCalled) } } } - postbindPlugin.reset() - prebindPlugin.reset() + postBindPlugin.reset() + preBindPlugin.reset() cleanupPods(cs, t, []*v1.Pod{pod}) } }