Skip to content

Extract preemption executor into Framework#137562

Closed
Argh4k wants to merge 1 commit intokubernetes:masterfrom
Argh4k:extract-executor-clean
Closed

Extract preemption executor into Framework#137562
Argh4k wants to merge 1 commit intokubernetes:masterfrom
Argh4k:extract-executor-clean

Conversation

@Argh4k
Copy link
Copy Markdown
Contributor

@Argh4k Argh4k commented Mar 9, 2026

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR is a prework for two other features: Workload Aware Preeemption from KEP-5710 and delayed preemption from KEP-4671. With that we make preemption a first class citizen in the scheduler framework, which will allow us to call the executor outside of the default preemption plugin.

Which issue(s) this PR is related to:

Special notes for your reviewer:

For now, the Preempt from preemption.go still actuates the preemptions if the Evaluator has the Executor set. In the future we should get rid of that completely and rely only on external Executor to actuate preemptions but I wanted to minimize the changes. This should result in no user-facing changes.

Does this PR introduce a user-facing change?

Preemption Executor is extracted out of preemption Evaluator. Authors of out of tree custom preemption plugins can pass Executor to Evaluator to keep the current behavior, or preferably call the Executor to actuate preemptions after Evaluator calculates them.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 9, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Mar 9, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in SIG Scheduling Mar 9, 2026
@k8s-ci-robot k8s-ci-robot requested review from denkensk and macsko March 9, 2026 08:25
@Argh4k
Copy link
Copy Markdown
Contributor Author

Argh4k commented Mar 9, 2026

/area workload-aware

@k8s-ci-robot k8s-ci-robot added the area/workload-aware Categorizes an issue or PR as relevant to Workload-aware and Topology-aware scheduling subprojects. label Mar 9, 2026
@Argh4k Argh4k changed the title Extract preemption executor from preemption Evaluator in default preemption Extract preemption executor into Framework Mar 9, 2026
@Argh4k
Copy link
Copy Markdown
Contributor Author

Argh4k commented Mar 9, 2026

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 9, 2026
@Argh4k Argh4k changed the title Extract preemption executor into Framework [WiP] Extract preemption executor into Framework Mar 9, 2026
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 9, 2026
@Argh4k Argh4k force-pushed the extract-executor-clean branch from 6404ffb to d476361 Compare March 9, 2026 11:36
@k8s-ci-robot k8s-ci-robot added area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Mar 9, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Argh4k
Once this PR has been reviewed and has the lgtm label, please assign dom4ha for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Argh4k Argh4k force-pushed the extract-executor-clean branch 2 times, most recently from 290a31c to dc03e8e Compare March 9, 2026 15:09
@Argh4k Argh4k changed the title [WiP] Extract preemption executor into Framework Extract preemption executor into Framework Mar 9, 2026
Comment on lines +386 to +388
for _, fwk := range profiles {
fwk.SetPreemptionExecutor(preemption.NewExecutor(fwk, plfeature.NewSchedulerFeaturesFromGates(feature.DefaultFeatureGate)))
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack. If so, could we open an issue for cleaning this up and mention it here with a TODO?

return nil
}
if pl.Evaluator.IsPodRunningPreemption(p.GetUID()) {
executor := pl.fh.PreemptionExecutor()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not make this a top-level field of DefaultPreemption struct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as with podLister, the executor is initialized after the plugins in the current scenario.

Comment thread pkg/scheduler/framework/preemption/preemption.go Outdated
func NewExecutor(fh fwk.Handle, fts feature.Features) *Executor {
e := &Executor{
fh: fh,
podLister: fh.SharedInformerFactory().Core().V1().Pods().Lister(),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok - in that case, leaving the decision what to do here to you - I don't have any strong opinion here :)

@Argh4k
Copy link
Copy Markdown
Contributor Author

Argh4k commented Mar 12, 2026

/retest

}()

executor := pl.fh.PreemptionExecutor()
if executor == nil {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check the nil? Isn't it always set?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With that I managed to quickly get some tests that were doing some manual initialization of scheduler, where I had to add also the initialization of preemption executor. So I would leave it as it is, as this check should not be expensive but it can allow for quicker debugging.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, can you add a comment that it can happen only in tests?

return nil, fwk.NewStatus(fwk.Error, "preemption executor is nil")
}

result, status := pl.Evaluator.Preempt(ctx, state, pod, m)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name Preempt becomes misleading now, because it only evaluates potential preemption without preempting anything

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether we can rename it directly. Given that I want to split Evaluator and Executor completely, I can:

  • add a note that use of executor in evaluator is deprecated and eventually will be removed
  • once the executor is removed from an evaluator rename the method.

WDYT?

Comment thread pkg/scheduler/framework/plugins/defaultpreemption/default_preemption.go Outdated
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 13, 2026
@helayoty helayoty moved this from Backlog to In Progress in Workload-aware & Topology-aware Workstream Mar 16, 2026
@helayoty helayoty moved this from In Progress to In Review in Workload-aware & Topology-aware Workstream Mar 16, 2026
@Argh4k Argh4k force-pushed the extract-executor-clean branch from 061a224 to 768ce00 Compare March 16, 2026 14:45
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 16, 2026
Copy link
Copy Markdown
Member

@sanposhiho sanposhiho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we need this effort decoupling executor from the preemption given we already dropped the delayed preemption.

I know we might need such if we really end up implementing the delayed preemption, but can we delay implementing it later? if this work is not particularly necessary for WAP implementation. As I commented in the other PR, I feel like it stays simpler if Preempt actually preempts pods.

@Argh4k Argh4k force-pushed the extract-executor-clean branch 2 times, most recently from 881160d to 484bf54 Compare March 17, 2026 08:34
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 17, 2026
@Argh4k
Copy link
Copy Markdown
Contributor Author

Argh4k commented Mar 17, 2026

I don't understand why we need this effort decoupling executor from the preemption given we already dropped the delayed preemption.

I know we might need such if we really end up implementing the delayed preemption, but can we delay implementing it later? if this work is not particularly necessary for WAP implementation. As I commented in the other PR, I feel like it stays simpler if Preempt actually preempts pods.

We still need to have Executor as a part of the framework to easily pass it to the pod group preemption evaluator in the pod group cycle. However the effort to call ActuatePreemption outside of the Evaluator.Preempt() can be removed. I will do so

@Argh4k Argh4k force-pushed the extract-executor-clean branch from 484bf54 to 0f497ca Compare March 17, 2026 11:01
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Mar 17, 2026
@Argh4k Argh4k force-pushed the extract-executor-clean branch from 0f497ca to 33af82a Compare March 17, 2026 11:07
@Argh4k
Copy link
Copy Markdown
Contributor Author

Argh4k commented Mar 17, 2026

@sanposhiho @macsko @tosi3k, so I removed the move of victim actuation outside of the Evalautor, but I kept the Executor as a part of the framework handle. I need that so in the main PR adding workload preemption, the same executor can be shared between pod group and pod evaluator, so we can check whether we run pod group preemption for given pod in the IsPodRunningPreemption method.

@Argh4k
Copy link
Copy Markdown
Contributor Author

Argh4k commented Mar 17, 2026

/retest

@Argh4k
Copy link
Copy Markdown
Contributor Author

Argh4k commented Mar 17, 2026

Also, given the limited time before 1.36 I lean towards closing this PR and just merging this as a part of the #137606.

The workload aware preemption is rebased on top of this one, including changes that resolved comments. @sanposhiho @tosi3k @macsko any objections?

@macsko
Copy link
Copy Markdown
Member

macsko commented Mar 17, 2026

Also, given the limited time before 1.36 I lean towards closing this PR and just merging this as a part of the #137606.

The workload aware preemption is rebased on top of this one, including changes that resolved comments.

Sounds good

@Argh4k
Copy link
Copy Markdown
Contributor Author

Argh4k commented Mar 17, 2026

Closing in favor of #137606

@Argh4k Argh4k closed this Mar 17, 2026
@github-project-automation github-project-automation Bot moved this from 1st Reviewer In Progress to Closed in SIG Scheduling Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/test area/workload-aware Categorizes an issue or PR as relevant to Workload-aware and Topology-aware scheduling subprojects. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants