Skip to content

Support configuring priority for NodeGroup when used by queue#5110

Open
ruanwenjun wants to merge 1 commit intovolcano-sh:masterfrom
ruanwenjun:dev_wenjun_supportNodeGroupOrderUpstream
Open

Support configuring priority for NodeGroup when used by queue#5110
ruanwenjun wants to merge 1 commit intovolcano-sh:masterfrom
ruanwenjun:dev_wenjun_supportNodeGroupOrderUpstream

Conversation

@ruanwenjun
Copy link
Contributor

@ruanwenjun ruanwenjun commented Mar 16, 2026

What type of PR is this?

feature

What this PR does / why we need it:

  • Supports sorting nodegroups

Which issue(s) this PR fixes:

Fixes #5109

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE, this is complated with the latest version.

Copilot AI review requested due to automatic review settings March 16, 2026 10:55
@volcano-sh-bot
Copy link
Contributor

[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 hwdef for approval. For more information see the Kubernetes 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

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant enhancement to the nodegroup scheduling plugin, allowing users to define explicit priority for preferred nodegroups. By enabling the enablePreferredOrder argument, the scheduler will now consider the order of nodegroups specified in a queue's affinity configuration, assigning higher scores to those listed earlier. This provides finer-grained control over task placement, ensuring that workloads prioritize specific resource pools before falling back to others, thereby improving resource utilization and operational efficiency.

Highlights

  • Nodegroup Priority Configuration: Introduced the ability to configure priority for NodeGroups within a queue's affinity settings.
  • enablePreferredOrder Argument: Added enablePreferredOrder to the nodegroup plugin arguments, which, when enabled, allows the order of preferred nodegroups to dictate their priority.
  • Dynamic Scoring Formula: Implemented a scoring formula (0.5 * BaseScore * (N - i) / N) to assign higher scores to earlier entries in the preferredDuringSchedulingIgnoredDuringExecution list.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • docs/design/node-group.md
    • Updated the description of preferredDuringSchedulingIgnoredDuringExecution to include the new priority ordering behavior and scoring formula when enablePreferredOrder is active.
    • Added enablePreferredOrder to the example nodegroup plugin configuration.
  • docs/user-guide/how_to_use_nodegroup_plugin.md
    • Added a new section "Preferred Nodegroup Priority Ordering" with detailed explanations, scheduler configuration, and queue configuration examples.
  • pkg/scheduler/plugins/nodegroup/nodegroup.go
    • Introduced enablePreferredOrder boolean field in the nodeGroupPlugin struct to control the new scoring logic.
    • Modified the New constructor to parse the enablePreferredOrder argument.
    • Added queueGroupAffinityPreferredList to queueGroupAffinity to store preferred nodegroups in order.
    • Updated newQueueGroupAffinity to populate queueGroupAffinityPreferredList.
    • Refactored the score method to conditionally apply the new position-based scoring formula when enablePreferredOrder is true, otherwise reverting to the default scoring.
    • Modified OnSessionOpen to pass the enablePreferredOrder flag to the score method.
  • pkg/scheduler/plugins/nodegroup/nodegroup_test.go
    • Added a new pod (p6) and pod group (pg6) for testing.
    • Created a new queue (queue3) with preferred nodegroups for testing priority.
    • Added a new test case "preferred nodegroup priority ordering" to validate the scoring logic with enablePreferredOrder set to true.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@volcano-sh-bot volcano-sh-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 16, 2026
@ruanwenjun ruanwenjun force-pushed the dev_wenjun_supportNodeGroupOrderUpstream branch from 34fb991 to d4cbdca Compare March 16, 2026 10:57
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new feature to allow prioritizing preferred nodegroups based on their order in the configuration. The changes are well-implemented across the documentation, application logic, and tests. I've included one suggestion to optimize the performance of the scoring logic, which is in a hot path.

Comment on lines +156 to +162
n := len(q.queueGroupAffinityPreferredList)
for i, preferred := range q.queueGroupAffinityPreferredList {
if preferred == group {
nodeScore += 0.5 * BaseScore * float64(n-i) / float64(n)
break
}
}

Choose a reason for hiding this comment

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

medium

For performance optimization, consider using a map for O(1) lookups instead of iterating through the queueGroupAffinityPreferredList slice in the score function. This function can be a hot path in the scheduler.

You can implement this with the following changes:

  1. Add a map to the queueGroupAffinity struct to store the index of each preferred nodegroup:

    // in queueGroupAffinity struct
    queueGroupAffinityPreferredMap map[string]int
  2. Populate this map in newQueueGroupAffinity after populating the list:

    // in newQueueGroupAffinity function
    affinity.queueGroupAffinityPreferredList = nodeGroupAffinity.PreferredDuringSchedulingIgnoredDuringExecution
    affinity.queueGroupAffinityPreferredMap = make(map[string]int, len(affinity.queueGroupAffinityPreferredList))
    for i, group := range affinity.queueGroupAffinityPreferredList {
        affinity.queueGroupAffinityPreferredMap[group] = i
    }
  3. Use the map for a direct lookup in the score function as suggested below.

if i, ok := q.queueGroupAffinityPreferredMap[group]; ok {
		n := len(q.queueGroupAffinityPreferredList)
		nodeScore += 0.5 * BaseScore * float64(n-i) / float64(n)
	}

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an optional “preferred nodegroup ordering” mode to the nodegroup scheduler plugin so that queues can prioritize earlier entries in preferredDuringSchedulingIgnoredDuringExecution when scoring nodes.

Changes:

  • Add enablePreferredOrder plugin argument and use list-order-based scoring for preferred nodegroups when enabled.
  • Extend nodegroup unit tests to cover ordered preferred scoring.
  • Document the new argument and scoring formula in user guide and design docs.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
pkg/scheduler/plugins/nodegroup/nodegroup.go Introduces enablePreferredOrder, stores preferred list order, and updates scoring logic to be position-based.
pkg/scheduler/plugins/nodegroup/nodegroup_test.go Adds a new test case validating ordered preferred scoring results.
docs/user-guide/how_to_use_nodegroup_plugin.md Documents how to enable and configure ordered preferred nodegroup scoring.
docs/design/node-group.md Updates design doc to describe the new ordered scoring behavior and configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +108 to 110
2. affinity.nodeGroupAffinity.preferredDuringSchedulingIgnoredDuringExecution, soft constraints, such as `nlp = nodegroup1`, it means that task in queue=nlp runs on nodegroup1 first, but if the resources of nodegroup1 is insufficient, it can also run on other nodegroups. Combine rule1 and rule2, task in queue=nlp runs on nodegroup1 first, but if the resources of nodegroup1 is insufficient, it can also run on nodegroup2. When `enablePreferredOrder` is enabled in plugin arguments, the order of the list determines priority — earlier entries get higher scores (score formula: `0.5 * BaseScore * (N - i) / N`). By default, all preferred nodegroups receive the same score.
3. affinity.nodeGroupAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution, hard constraints, such as `nlp = nodegroup1`, it means that task in queue=nlp can run on any nodegroups but nodegroup1.
4. affinity.nodeGroupAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution, soft constraints, such as `nlp = nodegroup1`, it means that task in queue=nlp runs on any other nodegroups, but if the resources of other nodegroup is insufficient, it can also run on nodegroup1.
@ruanwenjun ruanwenjun force-pushed the dev_wenjun_supportNodeGroupOrderUpstream branch from d4cbdca to decb9b7 Compare March 16, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support configuring priority for NodeGroup when used by queue

3 participants