Skip to content

[YUNIKORN-3237] DS Preemption: Improve victim selection algorithm - #1184

Open
PoiBlackTea wants to merge 2 commits into
apache:masterfrom
PoiBlackTea:YUNIKORN-3237
Open

PoiBlackTea wants to merge 2 commits into
apache:masterfrom
PoiBlackTea:YUNIKORN-3237

Conversation

@PoiBlackTea

@PoiBlackTea PoiBlackTea commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Description

This switches DS (required node) preemption to SortAllocationsBasedOnAsk, same as YUNIKORN-3236 did for inter-queue preemption. DS preemption only works on a single node, so I pass the node capacity as total. After this SortAllocations has no callers left, so I removed it together with its test.

Test changes: TestGetVictims still picks the same four victims, just in the new order. TestPlaceholderDataWithPlaceholderPreemption now creates the first five placeholders an hour earlier, so the last one is still the youngest victim.

Type of change

  • Bug Fix
  • Improvement
  • Feature
  • Refactoring
  • Documentation

Jira issue

Jira ID : https://issues.apache.org/jira/browse/YUNIKORN-3237

  • I have created a Jira issue for this pull request.
  • The Jira ID is part of the title of this pull request.

AI Tooling

If an AI tool was used:

  • The PR includes the phrase "Generated by Claude Code", where Claude Code is the name of the AI tool used.
  • My use of AI contributions follows the ASF legal policy.

Check https://www.apache.org/legal/generative-tooling.html for details.

How has this been tested?

  • New unit tests were added to cover new or changed code paths.
  • make test_all was run, and no failures reported.
  • A pull request will be opened for new e2e tests (apache/yunikorn-k8shim repository).

Questions:

  • The change needs documentation, a pull request for apache/yunikorn-site repository will be created.
  • There is breaking changes for older versions: jira is tagged with release-notes label.
  • The licenses files needs to be updated.

Screenshots or other details

NA

Sort required node preemption victims with SortAllocationsBasedOnAsk, using the node capacity as total, and remove the now unused SortAllocations. Update TestGetVictims and TestPlaceholderDataWithPlaceholderPreemption for the new victim order.
@PoiBlackTea
PoiBlackTea marked this pull request as ready for review October 6, 2026 14:36

@rjgoyln rjgoyln left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I left two notes below on BestEffort victims and test coverage for the new sort inputs.

Please feel free to resolve them if they’re not applicable.

Comment thread pkg/scheduler/objects/required_node_preemptor.go Outdated
Comment thread pkg/scheduler/objects/required_node_preemptor_test.go
@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.33%. Comparing base (c99a01f) to head (23a6d3f).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1184      +/-   ##
==========================================
+ Coverage   83.27%   83.33%   +0.06%     
==========================================
  Files         104      104              
  Lines       14460    14622     +162     
==========================================
+ Hits        12041    12185     +144     
- Misses       2131     2142      +11     
- Partials      288      295       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Use the resource types the node is short of as the sort reference, and add TestSortAllocations to cover the node capacity and shortfall inputs.

@rjgoyln rjgoyln left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants