Repository: kubernetes-sigs/descheduler
Pull request #1694 (2025-05-19 09:59:31)

Extend plugin's New with a context.Context
The new context.Context can be later used for passing a contextualized logger. Or, other initialization steps that require the context.

k8s-ci-robot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by:
**Once this PR has been reviewed and has the lgtm label**, please assign [ingvagabund](https://github.com/ingvagabund) for approval. For more information see [the Code Review Process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process).

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubernetes-sigs%2Fdescheduler).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/kubernetes-sigs/descheduler/blob/master/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["ingvagabund"]} -->
k8s-ci-robot: @ingvagabund: The following test **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-descheduler-verify-master | 32339aa17a5d19d329891dc7a95c31cf591e3b3e | [link](https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/kubernetes-sigs_descheduler/1694/pull-descheduler-verify-master/1924404555219472384) | true | `/test pull-descheduler-verify-master`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=descheduler&pr=1694). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Aingvagabund). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/descheduler/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
k8s-ci-robot: @ingvagabund: The following tests **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-descheduler-verify-master | 32339aa17a5d19d329891dc7a95c31cf591e3b3e | [link](https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/kubernetes-sigs_descheduler/1694/pull-descheduler-verify-master/1924404555219472384) | true | `/test pull-descheduler-verify-master`
pull-descheduler-test-e2e-k8s-master-1-32 | 32339aa17a5d19d329891dc7a95c31cf591e3b3e | [link](https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/kubernetes-sigs_descheduler/1694/pull-descheduler-test-e2e-k8s-master-1-32/1924404555529850880) | true | `/test pull-descheduler-test-e2e-k8s-master-1-32`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=descheduler&pr=1694). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Aingvagabund). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/descheduler/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
k8s-ci-robot: @ingvagabund: The following tests **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-descheduler-verify-master | 32339aa17a5d19d329891dc7a95c31cf591e3b3e | [link](https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/kubernetes-sigs_descheduler/1694/pull-descheduler-verify-master/1924404555219472384) | true | `/test pull-descheduler-verify-master`
pull-descheduler-test-e2e-k8s-master-1-32 | 32339aa17a5d19d329891dc7a95c31cf591e3b3e | [link](https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/kubernetes-sigs_descheduler/1694/pull-descheduler-test-e2e-k8s-master-1-32/1924404555529850880) | true | `/test pull-descheduler-test-e2e-k8s-master-1-32`
pull-descheduler-test-e2e-k8s-master-1-31 | 32339aa17a5d19d329891dc7a95c31cf591e3b3e | [link](https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/kubernetes-sigs_descheduler/1694/pull-descheduler-test-e2e-k8s-master-1-31/1924404555605348352) | true | `/test pull-descheduler-test-e2e-k8s-master-1-31`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=descheduler&pr=1694). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Aingvagabund). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/descheduler/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
k8s-ci-robot: @ingvagabund: The following tests **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-descheduler-verify-master | 32339aa17a5d19d329891dc7a95c31cf591e3b3e | [link](https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/kubernetes-sigs_descheduler/1694/pull-descheduler-verify-master/1924404555219472384) | true | `/test pull-descheduler-verify-master`
pull-descheduler-test-e2e-k8s-master-1-32 | 32339aa17a5d19d329891dc7a95c31cf591e3b3e | [link](https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/kubernetes-sigs_descheduler/1694/pull-descheduler-test-e2e-k8s-master-1-32/1924404555529850880) | true | `/test pull-descheduler-test-e2e-k8s-master-1-32`
pull-descheduler-test-e2e-k8s-master-1-31 | 32339aa17a5d19d329891dc7a95c31cf591e3b3e | [link](https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/kubernetes-sigs_descheduler/1694/pull-descheduler-test-e2e-k8s-master-1-31/1924404555605348352) | true | `/test pull-descheduler-test-e2e-k8s-master-1-31`
pull-descheduler-test-e2e-k8s-master-1-33 | 32339aa17a5d19d329891dc7a95c31cf591e3b3e | [link](https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/kubernetes-sigs_descheduler/1694/pull-descheduler-test-e2e-k8s-master-1-33/1924404555445964800) | true | `/test pull-descheduler-test-e2e-k8s-master-1-33`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=descheduler&pr=1694). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Aingvagabund). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/descheduler/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
k8s-ci-robot: @ingvagabund: The following tests **failed**, say `/retest` to rerun all failed tests or `/retest-required` to rerun all mandatory failed tests:

Test name | Commit | Details | Required | Rerun command
--- | --- | --- | --- | ---
pull-descheduler-test-e2e-k8s-master-1-32 | 32339aa17a5d19d329891dc7a95c31cf591e3b3e | [link](https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/kubernetes-sigs_descheduler/1694/pull-descheduler-test-e2e-k8s-master-1-32/1924404555529850880) | true | `/test pull-descheduler-test-e2e-k8s-master-1-32`
pull-descheduler-test-e2e-k8s-master-1-31 | 32339aa17a5d19d329891dc7a95c31cf591e3b3e | [link](https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/kubernetes-sigs_descheduler/1694/pull-descheduler-test-e2e-k8s-master-1-31/1924404555605348352) | true | `/test pull-descheduler-test-e2e-k8s-master-1-31`
pull-descheduler-test-e2e-k8s-master-1-33 | 32339aa17a5d19d329891dc7a95c31cf591e3b3e | [link](https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/kubernetes-sigs_descheduler/1694/pull-descheduler-test-e2e-k8s-master-1-33/1924404555445964800) | true | `/test pull-descheduler-test-e2e-k8s-master-1-33`
pull-descheduler-verify-master | bde613757cebe5297b59ddadc66c90a2b908b6f9 | [link](https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/pull/kubernetes-sigs_descheduler/1694/pull-descheduler-verify-master/1924407071285972992) | true | `/test pull-descheduler-verify-master`

[Full PR test history](https://prow.k8s.io/pr-history?org=kubernetes-sigs&repo=descheduler&pr=1694). [Your PR dashboard](https://prow.k8s.io/pr?query=is%3Apr%20state%3Aopen%20author%3Aingvagabund). Please help us cut down on flakes by [linking to](https://git.k8s.io/community/contributors/devel/sig-testing/flaky-tests.md#filing-issues-for-flaky-tests) an [open issue](https://github.com/kubernetes-sigs/descheduler/issues?q=is:issue+is:open) when you hit one in your PR.

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->

Patch:
diff --git a/pkg/descheduler/descheduler.go b/pkg/descheduler/descheduler.go
index 7a0979be2..1a7129c59 100644
--- a/pkg/descheduler/descheduler.go
+++ b/pkg/descheduler/descheduler.go
@@ -415,6 +415,7 @@ func (d *descheduler) runProfiles(ctx context.Context, client clientset.Interfac
 	var profileRunners []profileRunner
 	for _, profile := range d.deschedulerPolicy.Profiles {
 		currProfile, err := frameworkprofile.NewProfile(
+			ctx,
 			profile,
 			pluginregistry.PluginRegistry,
 			frameworkprofile.WithClientSet(client),
diff --git a/pkg/framework/fake/plugin/fake.go b/pkg/framework/fake/plugin/fake.go
index eb37dd5a4..c745a84e1 100644
--- a/pkg/framework/fake/plugin/fake.go
+++ b/pkg/framework/fake/plugin/fake.go
@@ -60,7 +60,7 @@ type FakePlugin struct {
 }
 
 func NewPluginFncFromFake(fp *FakePlugin) pluginregistry.PluginBuilder {
-	return func(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
+	return func(ctx context.Context, args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
 		fakePluginArgs, ok := args.(*FakePluginArgs)
 		if !ok {
 			return nil, fmt.Errorf("want args to be of type FakePluginArgs, got %T", args)
@@ -74,7 +74,7 @@ func NewPluginFncFromFake(fp *FakePlugin) pluginregistry.PluginBuilder {
 }
 
 // New builds plugin from its arguments while passing a handle
-func New(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
+func New(ctx context.Context, args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
 	fakePluginArgs, ok := args.(*FakePluginArgs)
 	if !ok {
 		return nil, fmt.Errorf("want args to be of type FakePluginArgs, got %T", args)
@@ -165,7 +165,7 @@ type FakeDeschedulePlugin struct {
 }
 
 func NewFakeDeschedulePluginFncFromFake(fp *FakeDeschedulePlugin) pluginregistry.PluginBuilder {
-	return func(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
+	return func(ctx context.Context, args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
 		fakePluginArgs, ok := args.(*FakeDeschedulePluginArgs)
 		if !ok {
 			return nil, fmt.Errorf("want args to be of type FakeDeschedulePluginArgs, got %T", args)
@@ -252,7 +252,7 @@ type FakeBalancePlugin struct {
 }
 
 func NewFakeBalancePluginFncFromFake(fp *FakeBalancePlugin) pluginregistry.PluginBuilder {
-	return func(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
+	return func(ctx context.Context, args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
 		fakePluginArgs, ok := args.(*FakeBalancePluginArgs)
 		if !ok {
 			return nil, fmt.Errorf("want args to be of type FakeBalancePluginArgs, got %T", args)
@@ -339,7 +339,7 @@ type FakeFilterPlugin struct {
 }
 
 func NewFakeFilterPluginFncFromFake(fp *FakeFilterPlugin) pluginregistry.PluginBuilder {
-	return func(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
+	return func(ctx context.Context, args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
 		fakePluginArgs, ok := args.(*FakeFilterPluginArgs)
 		if !ok {
 			return nil, fmt.Errorf("want args to be of type FakeFilterPluginArgs, got %T", args)
diff --git a/pkg/framework/pluginregistry/pluginregistry.go b/pkg/framework/pluginregistry/pluginregistry.go
index a200181db..2d74e4d8e 100644
--- a/pkg/framework/pluginregistry/pluginregistry.go
+++ b/pkg/framework/pluginregistry/pluginregistry.go
@@ -17,6 +17,8 @@ limitations under the License.
 package pluginregistry
 
 import (
+	"context"
+
 	"k8s.io/apimachinery/pkg/runtime"
 	"k8s.io/klog/v2"
 	frameworktypes "sigs.k8s.io/descheduler/pkg/framework/types"
@@ -35,7 +37,7 @@ type PluginUtilities struct {
 	PluginArgDefaulter PluginArgDefaulter
 }
 
-type PluginBuilder = func(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error)
+type PluginBuilder = func(ctx context.Context, args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error)
 
 type (
 	PluginArgValidator = func(args runtime.Object) error
diff --git a/pkg/framework/plugins/defaultevictor/defaultevictor.go b/pkg/framework/plugins/defaultevictor/defaultevictor.go
index f23bf13a1..186e437a9 100644
--- a/pkg/framework/plugins/defaultevictor/defaultevictor.go
+++ b/pkg/framework/plugins/defaultevictor/defaultevictor.go
@@ -66,7 +66,7 @@ func HaveEvictAnnotation(pod *v1.Pod) bool {
 
 // New builds plugin from its arguments while passing a handle
 // nolint: gocyclo
-func New(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
+func New(ctx context.Context, args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
 	defaultEvictorArgs, ok := args.(*DefaultEvictorArgs)
 	if !ok {
 		return nil, fmt.Errorf("want args to be of type defaultEvictorFilterArgs, got %T", args)
diff --git a/pkg/framework/plugins/example/example.go b/pkg/framework/plugins/example/example.go
index d9e64a4a1..8f68aeaea 100644
--- a/pkg/framework/plugins/example/example.go
+++ b/pkg/framework/plugins/example/example.go
@@ -55,7 +55,7 @@ type Example struct {
 // a runtime.Object. Handle is used by plugins to retrieve a kubernetes client
 // set, evictor interface, shared informer factory and other instruments shared
 // across different plugins.
-func New(args runtime.Object, handle fwtypes.Handle) (fwtypes.Plugin, error) {
+func New(ctx context.Context, args runtime.Object, handle fwtypes.Handle) (fwtypes.Plugin, error) {
 	// make sure we are receiving the right argument type.
 	exampleArgs, ok := args.(*ExampleArgs)
 	if !ok {
diff --git a/pkg/framework/plugins/nodeutilization/highnodeutilization.go b/pkg/framework/plugins/nodeutilization/highnodeutilization.go
index e2baa2037..17d8cbfcc 100644
--- a/pkg/framework/plugins/nodeutilization/highnodeutilization.go
+++ b/pkg/framework/plugins/nodeutilization/highnodeutilization.go
@@ -55,7 +55,7 @@ type HighNodeUtilization struct {
 
 // NewHighNodeUtilization builds plugin from its arguments while passing a handle.
 func NewHighNodeUtilization(
-	genericArgs runtime.Object, handle frameworktypes.Handle,
+	ctx context.Context, genericArgs runtime.Object, handle frameworktypes.Handle,
 ) (frameworktypes.Plugin, error) {
 	args, ok := genericArgs.(*HighNodeUtilizationArgs)
 	if !ok {
diff --git a/pkg/framework/plugins/nodeutilization/lownodeutilization.go b/pkg/framework/plugins/nodeutilization/lownodeutilization.go
index abc37aaf9..954b2eb32 100644
--- a/pkg/framework/plugins/nodeutilization/lownodeutilization.go
+++ b/pkg/framework/plugins/nodeutilization/lownodeutilization.go
@@ -57,7 +57,7 @@ type LowNodeUtilization struct {
 // handle. this plugin aims to move workload from overutilized nodes to
 // underutilized nodes.
 func NewLowNodeUtilization(
-	genericArgs runtime.Object, handle frameworktypes.Handle,
+	ctx context.Context, genericArgs runtime.Object, handle frameworktypes.Handle,
 ) (frameworktypes.Plugin, error) {
 	args, ok := genericArgs.(*LowNodeUtilizationArgs)
 	if !ok {
diff --git a/pkg/framework/plugins/podlifetime/pod_lifetime.go b/pkg/framework/plugins/podlifetime/pod_lifetime.go
index d451fea7c..a933f1e39 100644
--- a/pkg/framework/plugins/podlifetime/pod_lifetime.go
+++ b/pkg/framework/plugins/podlifetime/pod_lifetime.go
@@ -44,7 +44,7 @@ type PodLifeTime struct {
 }
 
 // New builds plugin from its arguments while passing a handle
-func New(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
+func New(ctx context.Context, args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
 	podLifeTimeArgs, ok := args.(*PodLifeTimeArgs)
 	if !ok {
 		return nil, fmt.Errorf("want args to be of type PodLifeTimeArgs, got %T", args)
diff --git a/pkg/framework/plugins/removeduplicates/removeduplicates.go b/pkg/framework/plugins/removeduplicates/removeduplicates.go
index 3d92ba8b0..94bbccbaa 100644
--- a/pkg/framework/plugins/removeduplicates/removeduplicates.go
+++ b/pkg/framework/plugins/removeduplicates/removeduplicates.go
@@ -62,7 +62,7 @@ func (po podOwner) String() string {
 }
 
 // New builds plugin from its arguments while passing a handle
-func New(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
+func New(ctx context.Context, args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
 	removeDuplicatesArgs, ok := args.(*RemoveDuplicatesArgs)
 	if !ok {
 		return nil, fmt.Errorf("want args to be of type RemoveDuplicatesArgs, got %T", args)
diff --git a/pkg/framework/plugins/removefailedpods/failedpods.go b/pkg/framework/plugins/removefailedpods/failedpods.go
index 8b1badc26..8c652bfd3 100644
--- a/pkg/framework/plugins/removefailedpods/failedpods.go
+++ b/pkg/framework/plugins/removefailedpods/failedpods.go
@@ -44,7 +44,7 @@ type RemoveFailedPods struct {
 var _ frameworktypes.DeschedulePlugin = &RemoveFailedPods{}
 
 // New builds plugin from its arguments while passing a handle
-func New(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
+func New(ctx context.Context, args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
 	failedPodsArgs, ok := args.(*RemoveFailedPodsArgs)
 	if !ok {
 		return nil, fmt.Errorf("want args to be of type RemoveFailedPodsArgs, got %T", args)
diff --git a/pkg/framework/plugins/removepodshavingtoomanyrestarts/toomanyrestarts.go b/pkg/framework/plugins/removepodshavingtoomanyrestarts/toomanyrestarts.go
index 4379fcd8d..17a7b5689 100644
--- a/pkg/framework/plugins/removepodshavingtoomanyrestarts/toomanyrestarts.go
+++ b/pkg/framework/plugins/removepodshavingtoomanyrestarts/toomanyrestarts.go
@@ -45,7 +45,7 @@ type RemovePodsHavingTooManyRestarts struct {
 var _ frameworktypes.DeschedulePlugin = &RemovePodsHavingTooManyRestarts{}
 
 // New builds plugin from its arguments while passing a handle
-func New(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
+func New(ctx context.Context, args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
 	tooManyRestartsArgs, ok := args.(*RemovePodsHavingTooManyRestartsArgs)
 	if !ok {
 		return nil, fmt.Errorf("want args to be of type RemovePodsHavingTooManyRestartsArgs, got %T", args)
diff --git a/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity.go b/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity.go
index 476566a18..aed11f15a 100644
--- a/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity.go
+++ b/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity.go
@@ -43,7 +43,7 @@ type RemovePodsViolatingInterPodAntiAffinity struct {
 var _ frameworktypes.DeschedulePlugin = &RemovePodsViolatingInterPodAntiAffinity{}
 
 // New builds plugin from its arguments while passing a handle
-func New(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
+func New(ctx context.Context, args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
 	interPodAntiAffinityArgs, ok := args.(*RemovePodsViolatingInterPodAntiAffinityArgs)
 	if !ok {
 		return nil, fmt.Errorf("want args to be of type RemovePodsViolatingInterPodAntiAffinityArgs, got %T", args)
diff --git a/pkg/framework/plugins/removepodsviolatingnodeaffinity/node_affinity.go b/pkg/framework/plugins/removepodsviolatingnodeaffinity/node_affinity.go
index 586ce2218..700a8fd67 100644
--- a/pkg/framework/plugins/removepodsviolatingnodeaffinity/node_affinity.go
+++ b/pkg/framework/plugins/removepodsviolatingnodeaffinity/node_affinity.go
@@ -41,7 +41,7 @@ type RemovePodsViolatingNodeAffinity struct {
 var _ frameworktypes.DeschedulePlugin = &RemovePodsViolatingNodeAffinity{}
 
 // New builds plugin from its arguments while passing a handle
-func New(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
+func New(ctx context.Context, args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
 	nodeAffinityArgs, ok := args.(*RemovePodsViolatingNodeAffinityArgs)
 	if !ok {
 		return nil, fmt.Errorf("want args to be of type RemovePodsViolatingNodeAffinityArgs, got %T", args)
diff --git a/pkg/framework/plugins/removepodsviolatingnodetaints/node_taint.go b/pkg/framework/plugins/removepodsviolatingnodetaints/node_taint.go
index a336f1c70..18455d3c3 100644
--- a/pkg/framework/plugins/removepodsviolatingnodetaints/node_taint.go
+++ b/pkg/framework/plugins/removepodsviolatingnodetaints/node_taint.go
@@ -44,7 +44,7 @@ type RemovePodsViolatingNodeTaints struct {
 var _ frameworktypes.DeschedulePlugin = &RemovePodsViolatingNodeTaints{}
 
 // New builds plugin from its arguments while passing a handle
-func New(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
+func New(ctx context.Context, args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
 	nodeTaintsArgs, ok := args.(*RemovePodsViolatingNodeTaintsArgs)
 	if !ok {
 		return nil, fmt.Errorf("want args to be of type RemovePodsViolatingNodeTaintsArgs, got %T", args)
diff --git a/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/topologyspreadconstraint.go b/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/topologyspreadconstraint.go
index 06d93e3f4..4505dffe0 100644
--- a/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/topologyspreadconstraint.go
+++ b/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/topologyspreadconstraint.go
@@ -74,7 +74,7 @@ type RemovePodsViolatingTopologySpreadConstraint struct {
 var _ frameworktypes.BalancePlugin = &RemovePodsViolatingTopologySpreadConstraint{}
 
 // New builds plugin from its arguments while passing a handle
-func New(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
+func New(ctx context.Context, args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plugin, error) {
 	pluginArgs, ok := args.(*RemovePodsViolatingTopologySpreadConstraintArgs)
 	if !ok {
 		return nil, fmt.Errorf("want args to be of type RemovePodsViolatingTopologySpreadConstraintArgs, got %T", args)
diff --git a/pkg/framework/profile/profile.go b/pkg/framework/profile/profile.go
index 16d81d738..cd51accf0 100644
--- a/pkg/framework/profile/profile.go
+++ b/pkg/framework/profile/profile.go
@@ -191,7 +191,7 @@ func getPluginConfig(pluginName string, pluginConfigs []api.PluginConfig) (*api.
 	return nil, 0
 }
 
-func buildPlugin(config api.DeschedulerProfile, pluginName string, handle *handleImpl, reg pluginregistry.Registry) (frameworktypes.Plugin, error) {
+func buildPlugin(ctx context.Context, config api.DeschedulerProfile, pluginName string, handle *handleImpl, reg pluginregistry.Registry) (frameworktypes.Plugin, error) {
 	pc, _ := getPluginConfig(pluginName, config.PluginConfigs)
 	if pc == nil {
 		klog.ErrorS(fmt.Errorf("unable to get plugin config"), "skipping plugin", "plugin", pluginName, "profile", config.Name)
@@ -203,7 +203,7 @@ func buildPlugin(config api.DeschedulerProfile, pluginName string, handle *handl
 		klog.ErrorS(fmt.Errorf("unable to find plugin in the pluginsMap"), "skipping plugin", "plugin", pluginName)
 		return nil, fmt.Errorf("unable to find %q plugin in the pluginsMap", pluginName)
 	}
-	pg, err := registryPlugin.PluginBuilder(pc.Args, handle)
+	pg, err := registryPlugin.PluginBuilder(ctx, pc.Args, handle)
 	if err != nil {
 		klog.ErrorS(err, "unable to initialize a plugin", "pluginName", pluginName)
 		return nil, fmt.Errorf("unable to initialize %q plugin: %v", pluginName, err)
@@ -231,7 +231,7 @@ func (p *profileImpl) registryToExtensionPoints(registry pluginregistry.Registry
 	}
 }
 
-func NewProfile(config api.DeschedulerProfile, reg pluginregistry.Registry, opts ...Option) (*profileImpl, error) {
+func NewProfile(ctx context.Context, config api.DeschedulerProfile, reg pluginregistry.Registry, opts ...Option) (*profileImpl, error) {
 	hOpts := &handleImplOpts{}
 	for _, optFnc := range opts {
 		optFnc(hOpts)
@@ -290,7 +290,7 @@ func NewProfile(config api.DeschedulerProfile, reg pluginregistry.Registry, opts
 
 	plugins := make(map[string]frameworktypes.Plugin)
 	for _, plugin := range sets.New(pluginNames...).UnsortedList() {
-		pg, err := buildPlugin(config, plugin, handle, reg)
+		pg, err := buildPlugin(ctx, config, plugin, handle, reg)
 		if err != nil {
 			return nil, fmt.Errorf("unable to build %v plugin: %v", plugin, err)
 		}


Test patch:
diff --git a/pkg/framework/plugins/defaultevictor/defaultevictor_test.go b/pkg/framework/plugins/defaultevictor/defaultevictor_test.go
index 3656340a1..e176e39a3 100644
--- a/pkg/framework/plugins/defaultevictor/defaultevictor_test.go
+++ b/pkg/framework/plugins/defaultevictor/defaultevictor_test.go
@@ -858,7 +858,7 @@ func TestReinitialization(t *testing.T) {
 			if !ok {
 				t.Fatalf("Unable to initialize as a DefaultEvictor plugin")
 			}
-			_, err = New(defaultEvictor.args, defaultEvictor.handle)
+			_, err = New(ctx, defaultEvictor.args, defaultEvictor.handle)
 			if err != nil {
 				t.Fatalf("Unable to reinitialize the plugin: %v", err)
 			}
@@ -907,6 +907,7 @@ func initializePlugin(ctx context.Context, test testCase) (frameworktypes.Plugin
 	}
 
 	evictorPlugin, err := New(
+		ctx,
 		defaultEvictorArgs,
 		&frameworkfake.HandleImpl{
 			ClientsetImpl:                 fakeClient,
diff --git a/pkg/framework/plugins/nodeutilization/highnodeutilization_test.go b/pkg/framework/plugins/nodeutilization/highnodeutilization_test.go
index 15903012b..1e7297f2e 100644
--- a/pkg/framework/plugins/nodeutilization/highnodeutilization_test.go
+++ b/pkg/framework/plugins/nodeutilization/highnodeutilization_test.go
@@ -523,6 +523,7 @@ func TestHighNodeUtilization(t *testing.T) {
 			}
 
 			plugin, err := NewHighNodeUtilization(
+				ctx,
 				&HighNodeUtilizationArgs{
 					Thresholds:    testCase.thresholds,
 					EvictionModes: testCase.evictionModes,
@@ -637,7 +638,7 @@ func TestHighNodeUtilizationWithTaints(t *testing.T) {
 				t.Fatalf("Unable to initialize a framework handle: %v", err)
 			}
 
-			plugin, err := NewHighNodeUtilization(&HighNodeUtilizationArgs{
+			plugin, err := NewHighNodeUtilization(ctx, &HighNodeUtilizationArgs{
 				Thresholds: api.ResourceThresholds{
 					v1.ResourceCPU: 40,
 				},
diff --git a/pkg/framework/plugins/nodeutilization/lownodeutilization_test.go b/pkg/framework/plugins/nodeutilization/lownodeutilization_test.go
index 28cf880e9..4cfd10240 100644
--- a/pkg/framework/plugins/nodeutilization/lownodeutilization_test.go
+++ b/pkg/framework/plugins/nodeutilization/lownodeutilization_test.go
@@ -1391,7 +1391,7 @@ func TestLowNodeUtilization(t *testing.T) {
 					metricsUtilization = &MetricsUtilization{Source: api.KubernetesMetrics}
 				}
 
-				plugin, err := NewLowNodeUtilization(&LowNodeUtilizationArgs{
+				plugin, err := NewLowNodeUtilization(ctx, &LowNodeUtilizationArgs{
 					Thresholds:             tc.thresholds,
 					TargetThresholds:       tc.targetThresholds,
 					UseDeviationThresholds: tc.useDeviationThresholds,
@@ -1551,7 +1551,7 @@ func TestLowNodeUtilizationWithTaints(t *testing.T) {
 				t.Fatalf("Unable to initialize a framework handle: %v", err)
 			}
 
-			plugin, err := NewLowNodeUtilization(&LowNodeUtilizationArgs{
+			plugin, err := NewLowNodeUtilization(ctx, &LowNodeUtilizationArgs{
 				Thresholds: api.ResourceThresholds{
 					v1.ResourcePods: 20,
 				},
@@ -1824,7 +1824,7 @@ func TestLowNodeUtilizationWithPrometheusMetrics(t *testing.T) {
 					result:   tc.samples,
 					dataType: model.ValVector,
 				}
-				plugin, err := NewLowNodeUtilization(tc.args, handle)
+				plugin, err := NewLowNodeUtilization(ctx, tc.args, handle)
 				if err != nil {
 					t.Fatalf("Unable to initialize the plugin: %v", err)
 				}
diff --git a/pkg/framework/plugins/podlifetime/pod_lifetime_test.go b/pkg/framework/plugins/podlifetime/pod_lifetime_test.go
index 71e87965d..19bbe2572 100644
--- a/pkg/framework/plugins/podlifetime/pod_lifetime_test.go
+++ b/pkg/framework/plugins/podlifetime/pod_lifetime_test.go
@@ -643,7 +643,7 @@ func TestPodLifeTime(t *testing.T) {
 				t.Fatalf("Unable to initialize a framework handle: %v", err)
 			}
 
-			plugin, err := New(tc.args, handle)
+			plugin, err := New(ctx, tc.args, handle)
 			if err != nil {
 				t.Fatalf("Unable to initialize the plugin: %v", err)
 			}
diff --git a/pkg/framework/plugins/removeduplicates/removeduplicates_test.go b/pkg/framework/plugins/removeduplicates/removeduplicates_test.go
index 6bde4ea79..4b3eeb545 100644
--- a/pkg/framework/plugins/removeduplicates/removeduplicates_test.go
+++ b/pkg/framework/plugins/removeduplicates/removeduplicates_test.go
@@ -299,7 +299,7 @@ func TestFindDuplicatePods(t *testing.T) {
 				t.Fatalf("Unable to initialize a framework handle: %v", err)
 			}
 
-			plugin, err := New(&RemoveDuplicatesArgs{
+			plugin, err := New(ctx, &RemoveDuplicatesArgs{
 				ExcludeOwnerKinds: testCase.excludeOwnerKinds,
 			},
 				handle,
@@ -702,7 +702,7 @@ func TestRemoveDuplicatesUniformly(t *testing.T) {
 				t.Fatalf("Unable to initialize a framework handle: %v", err)
 			}
 
-			plugin, err := New(&RemoveDuplicatesArgs{},
+			plugin, err := New(ctx, &RemoveDuplicatesArgs{},
 				handle,
 			)
 			if err != nil {
diff --git a/pkg/framework/plugins/removefailedpods/failedpods_test.go b/pkg/framework/plugins/removefailedpods/failedpods_test.go
index 77fc478ef..010478e94 100644
--- a/pkg/framework/plugins/removefailedpods/failedpods_test.go
+++ b/pkg/framework/plugins/removefailedpods/failedpods_test.go
@@ -362,7 +362,7 @@ func TestRemoveFailedPods(t *testing.T) {
 				t.Fatalf("Unable to initialize a framework handle: %v", err)
 			}
 
-			plugin, err := New(&RemoveFailedPodsArgs{
+			plugin, err := New(ctx, &RemoveFailedPodsArgs{
 				Reasons:                 tc.args.Reasons,
 				ExitCodes:               tc.args.ExitCodes,
 				MinPodLifetimeSeconds:   tc.args.MinPodLifetimeSeconds,
diff --git a/pkg/framework/plugins/removepodshavingtoomanyrestarts/toomanyrestarts_test.go b/pkg/framework/plugins/removepodshavingtoomanyrestarts/toomanyrestarts_test.go
index c9336c235..20bcbdaaa 100644
--- a/pkg/framework/plugins/removepodshavingtoomanyrestarts/toomanyrestarts_test.go
+++ b/pkg/framework/plugins/removepodshavingtoomanyrestarts/toomanyrestarts_test.go
@@ -341,6 +341,7 @@ func TestRemovePodsHavingTooManyRestarts(t *testing.T) {
 			}
 
 			plugin, err := New(
+				ctx,
 				&tc.args,
 				handle)
 			if err != nil {
diff --git a/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity_test.go b/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity_test.go
index 255a45c07..1b6affa2d 100644
--- a/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity_test.go
+++ b/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity_test.go
@@ -240,6 +240,7 @@ func TestPodAntiAffinity(t *testing.T) {
 			}
 
 			plugin, err := New(
+				ctx,
 				&RemovePodsViolatingInterPodAntiAffinityArgs{},
 				handle,
 			)
diff --git a/pkg/framework/plugins/removepodsviolatingnodeaffinity/node_affinity_test.go b/pkg/framework/plugins/removepodsviolatingnodeaffinity/node_affinity_test.go
index 4077ec64b..fe6029fd5 100644
--- a/pkg/framework/plugins/removepodsviolatingnodeaffinity/node_affinity_test.go
+++ b/pkg/framework/plugins/removepodsviolatingnodeaffinity/node_affinity_test.go
@@ -369,6 +369,7 @@ func TestRemovePodsViolatingNodeAffinity(t *testing.T) {
 			}
 
 			plugin, err := New(
+				ctx,
 				&RemovePodsViolatingNodeAffinityArgs{
 					NodeAffinityType: tc.args.NodeAffinityType,
 				},
diff --git a/pkg/framework/plugins/removepodsviolatingnodetaints/node_taint_test.go b/pkg/framework/plugins/removepodsviolatingnodetaints/node_taint_test.go
index ab4459fd7..0a6abbe1a 100644
--- a/pkg/framework/plugins/removepodsviolatingnodetaints/node_taint_test.go
+++ b/pkg/framework/plugins/removepodsviolatingnodetaints/node_taint_test.go
@@ -425,7 +425,7 @@ func TestDeletePodsViolatingNodeTaints(t *testing.T) {
 				t.Fatalf("Unable to initialize a framework handle: %v", err)
 			}
 
-			plugin, err := New(&RemovePodsViolatingNodeTaintsArgs{
+			plugin, err := New(ctx, &RemovePodsViolatingNodeTaintsArgs{
 				IncludePreferNoSchedule: tc.includePreferNoSchedule,
 				ExcludedTaints:          tc.excludedTaints,
 				IncludedTaints:          tc.includedTaints,
diff --git a/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/topologyspreadconstraint_test.go b/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/topologyspreadconstraint_test.go
index 0355f5df3..bf5033458 100644
--- a/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/topologyspreadconstraint_test.go
+++ b/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/topologyspreadconstraint_test.go
@@ -1449,6 +1449,7 @@ func TestTopologySpreadConstraint(t *testing.T) {
 			SetDefaults_RemovePodsViolatingTopologySpreadConstraintArgs(&tc.args)
 
 			plugin, err := New(
+				ctx,
 				&tc.args,
 				handle,
 			)
diff --git a/pkg/framework/profile/profile_test.go b/pkg/framework/profile/profile_test.go
index 91a7f9521..5eeebb602 100644
--- a/pkg/framework/profile/profile_test.go
+++ b/pkg/framework/profile/profile_test.go
@@ -242,6 +242,7 @@ func TestProfileDescheduleBalanceExtensionPointsEviction(t *testing.T) {
 			}
 
 			prfl, err := NewProfile(
+				ctx,
 				test.config,
 				pluginregistry.PluginRegistry,
 				WithClientSet(client),
@@ -385,6 +386,7 @@ func TestProfileExtensionPoints(t *testing.T) {
 	}
 
 	prfl, err := NewProfile(
+		ctx,
 		api.DeschedulerProfile{
 			Name: "strategy-test-profile",
 			PluginConfigs: []api.PluginConfig{
@@ -592,6 +594,7 @@ func TestProfileExtensionPointOrdering(t *testing.T) {
 	}
 
 	prfl, err := NewProfile(
+		ctx,
 		api.DeschedulerProfile{
 			Name: "strategy-test-profile",
 			PluginConfigs: []api.PluginConfig{
diff --git a/pkg/framework/testing/utils.go b/pkg/framework/testing/utils.go
index f5b4fe7d6..ac646c25c 100644
--- a/pkg/framework/testing/utils.go
+++ b/pkg/framework/testing/utils.go
@@ -55,6 +55,7 @@ func InitFrameworkHandle(
 		return nil, nil, fmt.Errorf("Unable to initialize pod evictor: %v", err)
 	}
 	evictorFilter, err := defaultevictor.New(
+		ctx,
 		&defaultEvictorArgs,
 		&frameworkfake.HandleImpl{
 			ClientsetImpl:                 client,
diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go
index 736d19f89..22d266e16 100644
--- a/test/e2e/e2e_test.go
+++ b/test/e2e/e2e_test.go
@@ -451,7 +451,7 @@ func runPodLifetimePlugin(
 
 	maxPodLifeTimeSeconds := uint(1)
 
-	plugin, err := podlifetime.New(&podlifetime.PodLifeTimeArgs{
+	plugin, err := podlifetime.New(ctx, &podlifetime.PodLifeTimeArgs{
 		MaxPodLifeTimeSeconds: &maxPodLifeTimeSeconds,
 		LabelSelector:         labelSelector,
 		Namespaces:            namespaces,
@@ -615,7 +615,7 @@ func TestLowNodeUtilization(t *testing.T) {
 	podsBefore := len(podsOnMosttUtilizedNode)
 
 	t.Log("Running LowNodeUtilization plugin")
-	plugin, err := nodeutilization.NewLowNodeUtilization(&nodeutilization.LowNodeUtilizationArgs{
+	plugin, err := nodeutilization.NewLowNodeUtilization(ctx, &nodeutilization.LowNodeUtilizationArgs{
 		Thresholds: api.ResourceThresholds{
 			v1.ResourceCPU: 70,
 		},