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:
Mengjiao Liu
2023-09-06 11:55:33 +08:00
parent f9f00da6bc
commit a7466f44e0
53 changed files with 287 additions and 218 deletions

View File

@@ -243,7 +243,7 @@ func (pl *NodeAffinity) ScoreExtensions() framework.ScoreExtensions {
}
// New initializes a new plugin and returns it.
func New(plArgs runtime.Object, h framework.Handle) (framework.Plugin, error) {
func New(_ context.Context, plArgs runtime.Object, h framework.Handle) (framework.Plugin, error) {
args, err := getArgs(plArgs)
if err != nil {
return nil, err

View File

@@ -896,6 +896,7 @@ func TestNodeAffinity(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
_, ctx := ktesting.NewTestContext(t)
node := v1.Node{ObjectMeta: metav1.ObjectMeta{
Name: test.nodeName,
Labels: test.labels,
@@ -903,7 +904,7 @@ func TestNodeAffinity(t *testing.T) {
nodeInfo := framework.NewNodeInfo()
nodeInfo.SetNode(&node)
p, err := New(&test.args, nil)
p, err := New(ctx, &test.args, nil)
if err != nil {
t.Fatalf("Creating plugin: %v", err)
}
@@ -1141,7 +1142,7 @@ func TestNodeAffinityPriority(t *testing.T) {
state := framework.NewCycleState()
fh, _ := runtime.NewFramework(ctx, nil, nil, runtime.WithSnapshotSharedLister(cache.NewSnapshot(nil, test.nodes)))
p, err := New(&test.args, fh)
p, err := New(ctx, &test.args, fh)
if err != nil {
t.Fatalf("Creating plugin: %v", err)
}