diff --git a/pkg/scheduler/framework/v1alpha1/framework.go b/pkg/scheduler/framework/v1alpha1/framework.go index 2c8c0aca676..8d186fc23f4 100644 --- a/pkg/scheduler/framework/v1alpha1/framework.go +++ b/pkg/scheduler/framework/v1alpha1/framework.go @@ -47,7 +47,7 @@ type framework struct { reservePlugins []ReservePlugin prebindPlugins []PrebindPlugin bindPlugins []BindPlugin - postbindPlugins []PostbindPlugin + postBindPlugins []PostBindPlugin unreservePlugins []UnreservePlugin permitPlugins []PermitPlugin } @@ -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) } @@ -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 7af0d87cc98..251e20b984c 100644 --- a/pkg/scheduler/framework/v1alpha1/interface.go +++ b/pkg/scheduler/framework/v1alpha1/interface.go @@ -234,15 +234,15 @@ type PrebindPlugin interface { 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 @@ -318,8 +318,8 @@ type Framework interface { // internal error. In either case the pod is not going to be bound. 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 0c6b7a7148d..1b53474401c 100644 --- a/pkg/scheduler/internal/queue/scheduling_queue_test.go +++ b/pkg/scheduler/internal/queue/scheduling_queue_test.go @@ -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..6aba9507e6f 100644 --- a/pkg/scheduler/scheduler.go +++ b/pkg/scheduler/scheduler.go @@ -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 074595da0f6..03a2d5d6d71 100644 --- a/test/integration/scheduler/framework_test.go +++ b/test/integration/scheduler/framework_test.go @@ -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 } @@ -109,7 +109,7 @@ const ( reservePluginName = "reserve-plugin" prebindPluginName = "prebind-plugin" unreservePluginName = "unreserve-plugin" - postbindPluginName = "postbind-plugin" + postBindPluginName = "postbind-plugin" permitPluginName = "permit-plugin" ) @@ -122,7 +122,7 @@ var _ = framework.ReservePlugin(&ReservePlugin{}) var _ = framework.PostFilterPlugin(&PostFilterPlugin{}) var _ = framework.PrebindPlugin(&PrebindPlugin{}) var _ = framework.BindPlugin(&BindPlugin{}) -var _ = framework.PostbindPlugin(&PostbindPlugin{}) +var _ = framework.PostBindPlugin(&PostBindPlugin{}) var _ = framework.UnreservePlugin(&UnreservePlugin{}) var _ = framework.PermitPlugin(&PermitPlugin{}) @@ -303,21 +303,21 @@ 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. @@ -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} + postBindPlugin := &PostBindPlugin{name: postBindPluginName} registry := framework.Registry{ prebindPluginName: newPlugin(prebindPlugin), - postbindPluginName: newPlugin(postbindPlugin), + postBindPluginName: newPlugin(postBindPlugin), } // Setup initial prebind and postbind plugin for testing. @@ -1087,7 +1087,7 @@ func TestPostbindPlugin(t *testing.T) { PostBind: &schedulerconfig.PluginSet{ Enabled: []schedulerconfig.Plugin{ { - Name: postbindPluginName, + Name: postBindPluginName, }, }, }, @@ -1099,7 +1099,7 @@ func TestPostbindPlugin(t *testing.T) { Args: runtime.Unknown{}, }, { - Name: postbindPluginName, + Name: postBindPluginName, Args: runtime.Unknown{}, }, } @@ -1154,28 +1154,28 @@ func TestPostbindPlugin(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) } } else { 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() + postBindPlugin.reset() prebindPlugin.reset() cleanupPods(cs, t, []*v1.Pod{pod}) }