Change the scheduler plugins PluginFactory function to use context parameter to pass logger
- Migrated pkg/scheduler/framework/plugins/nodevolumelimits to use contextual logging - Fix golangci-lint validation failed - Check for plugins creation err
This commit is contained in:
@@ -62,7 +62,7 @@ var (
|
||||
|
||||
// newPlugin returns a plugin factory with specified Plugin.
|
||||
func newPlugin(plugin framework.Plugin) frameworkruntime.PluginFactory {
|
||||
return func(_ runtime.Object, fh framework.Handle) (framework.Plugin, error) {
|
||||
return func(_ context.Context, _ runtime.Object, fh framework.Handle) (framework.Plugin, error) {
|
||||
switch pl := plugin.(type) {
|
||||
case *PermitPlugin:
|
||||
pl.fh = fh
|
||||
@@ -2518,7 +2518,7 @@ func (j *JobPlugin) PostBind(_ context.Context, state *framework.CycleState, p *
|
||||
func TestActivatePods(t *testing.T) {
|
||||
var jobPlugin *JobPlugin
|
||||
// Create a plugin registry for testing. Register a Job plugin.
|
||||
registry := frameworkruntime.Registry{jobPluginName: func(_ runtime.Object, fh framework.Handle) (framework.Plugin, error) {
|
||||
registry := frameworkruntime.Registry{jobPluginName: func(_ context.Context, _ runtime.Object, fh framework.Handle) (framework.Plugin, error) {
|
||||
jobPlugin = &JobPlugin{podLister: fh.SharedInformerFactory().Core().V1().Pods().Lister()}
|
||||
return jobPlugin, nil
|
||||
}}
|
||||
|
@@ -159,7 +159,7 @@ func TestPreemption(t *testing.T) {
|
||||
// Initialize scheduler with a filter plugin.
|
||||
var filter tokenFilter
|
||||
registry := make(frameworkruntime.Registry)
|
||||
err := registry.Register(filterPluginName, func(_ runtime.Object, fh framework.Handle) (framework.Plugin, error) {
|
||||
err := registry.Register(filterPluginName, func(_ context.Context, _ runtime.Object, fh framework.Handle) (framework.Plugin, error) {
|
||||
return &filter, nil
|
||||
})
|
||||
if err != nil {
|
||||
@@ -1046,7 +1046,7 @@ func (af *alwaysFail) PreBind(_ context.Context, _ *framework.CycleState, p *v1.
|
||||
return framework.NewStatus(framework.Unschedulable)
|
||||
}
|
||||
|
||||
func newAlwaysFail(_ runtime.Object, _ framework.Handle) (framework.Plugin, error) {
|
||||
func newAlwaysFail(_ context.Context, _ runtime.Object, _ framework.Handle) (framework.Plugin, error) {
|
||||
return &alwaysFail{}, nil
|
||||
}
|
||||
|
||||
|
@@ -340,7 +340,7 @@ func TestCustomResourceEnqueue(t *testing.T) {
|
||||
}
|
||||
|
||||
registry := frameworkruntime.Registry{
|
||||
"fakeCRPlugin": func(_ runtime.Object, fh framework.Handle) (framework.Plugin, error) {
|
||||
"fakeCRPlugin": func(_ context.Context, _ runtime.Object, fh framework.Handle) (framework.Plugin, error) {
|
||||
return &fakeCRPlugin{}, nil
|
||||
},
|
||||
}
|
||||
@@ -447,8 +447,8 @@ func TestCustomResourceEnqueue(t *testing.T) {
|
||||
func TestRequeueByBindFailure(t *testing.T) {
|
||||
fakeBind := &firstFailBindPlugin{}
|
||||
registry := frameworkruntime.Registry{
|
||||
"firstFailBindPlugin": func(o runtime.Object, fh framework.Handle) (framework.Plugin, error) {
|
||||
binder, err := defaultbinder.New(nil, fh)
|
||||
"firstFailBindPlugin": func(ctx context.Context, o runtime.Object, fh framework.Handle) (framework.Plugin, error) {
|
||||
binder, err := defaultbinder.New(ctx, nil, fh)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -539,7 +539,7 @@ func TestRequeueByPermitRejection(t *testing.T) {
|
||||
queueingHintCalledCounter := 0
|
||||
fakePermit := &fakePermitPlugin{}
|
||||
registry := frameworkruntime.Registry{
|
||||
fakePermitPluginName: func(o runtime.Object, fh framework.Handle) (framework.Plugin, error) {
|
||||
fakePermitPluginName: func(ctx context.Context, o runtime.Object, fh framework.Handle) (framework.Plugin, error) {
|
||||
fakePermit = &fakePermitPlugin{
|
||||
frameworkHandler: fh,
|
||||
schedulingHint: func(logger klog.Logger, pod *v1.Pod, oldObj, newObj interface{}) framework.QueueingHint {
|
||||
|
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package scheduler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -81,7 +82,7 @@ func InitTestSchedulerForFrameworkTest(t *testing.T, testCtx *testutils.TestCont
|
||||
|
||||
// NewPlugin returns a plugin factory with specified Plugin.
|
||||
func NewPlugin(plugin framework.Plugin) frameworkruntime.PluginFactory {
|
||||
return func(_ runtime.Object, fh framework.Handle) (framework.Plugin, error) {
|
||||
return func(_ context.Context, _ runtime.Object, fh framework.Handle) (framework.Plugin, error) {
|
||||
return plugin, nil
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user