Skip to content

TAS: infer flavor for grouped PodSets with no managed resource requests - #12562

Merged
kubernetes-prow[bot] merged 1 commit into
kubernetes-sigs:mainfrom
epam:fix/12417-lws-leader-with-no-request
Aug 4, 2026
Merged

kubernetes-prow[bot] merged 1 commit into
kubernetes-sigs:mainfrom
epam:fix/12417-lws-leader-with-no-request

Conversation

@mszadkow

@mszadkow mszadkow commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind bug
/kind regression
/area tas
/area integrations

What this PR does / why we need it:

When a TAS-enabled Workload has a PodSet that requests none of its ClusterQueue's
managed resources, Kueue's flavor assigner previously left that PodSet's flavor
unresolved and rejected it with no TAS flavor assigned.

This PR resolves the flavor for such a PodSet by inheriting the TAS flavor already resolved for its PodSet group, instead of being filtered down to an empty flavor set.

If this can't be applied the PodSet still correctly fails, since there is no information to determine which flavor it should use.

Which issue(s) this PR fixes:

Fixes #12417

Special notes for your reviewer:

Does this PR introduce a user-facing change?

TAS: Fixed a bug where a grouped PodSet (e.g. an LWS leader) with no requests for the TAS-managed resource was rejected with "no TAS flavor assigned".

Summary by CodeRabbit

Summary

  • Bug Fixes

    • Improved TAS flavor assignment for grouped pod sets, including leader/worker behavior when the leader has no managed resource requests but is part of a topology-aware group.
    • Enhanced conflict detection and clearer failure behavior when multiple TAS flavors could be assigned (while preserving worker pod set assignments where applicable).
    • Now rejects required topology requests for ElasticJobs using workload slices, with the error surfaced on the affected pod set.
  • Tests

    • Added regression coverage for grouped leader/worker TAS resolution and the ElasticJobs required-topology rejection case.

@kubernetes-prow

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@kubernetes-prow kubernetes-prow Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. kind/regression Categorizes issue or PR as related to a regression from a prior release. area/tas Topology-Aware Scheduling area/integrations Workload integrations labels Jun 26, 2026
@netlify

netlify Bot commented Jun 26, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for kubernetes-sigs-kueue canceled.

Name Link
🔨 Latest commit cd4cd15
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-kueue/deploys/6a724f0a4b6b8b0008afafea

@coderabbitai

coderabbitai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds TAS flavor resolution for request-less pod sets, switches TAS error handling to sentinel values, and expands regression coverage for leader/worker assignment and elastic workload topology rejection.

Changes

TAS flavor resolution updates

Layer / File(s) Summary
TAS error helpers
pkg/scheduler/flavorassigner/tas_flavorassigner.go
Sentinel TAS error values are added and used when selecting a single TAS flavor or filtering assignments by TAS flavors.
Podset flavor resolution
pkg/scheduler/flavorassigner/flavorassigner.go, pkg/scheduler/flavorassigner/tas_flavorassigner.go
Grouped flavor assignment delegates podset flavor selection to resolvePodSetFlavors, which preserves TAS flavors for request-less topology groups and falls back to a single CQ flavor when applicable.
Regression tests
pkg/scheduler/flavorassigner/flavorassigner_test.go
New tests cover leader/worker TAS flavor assignment and rejection of required topology in elastic workload slices.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: kannon92, olekzabl, sohankunkerkar

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address #12417 by resolving TAS flavors for request-less grouped LWS PodSets and preserving the expected admission behavior.
Out of Scope Changes check ✅ Passed The modified tests and TAS flavor-assignment helpers all support the reported regression fix and do not appear unrelated.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: inferring TAS flavors for grouped PodSets without managed resource requests.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kubernetes-prow kubernetes-prow Bot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 26, 2026
@kubernetes-prow kubernetes-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 26, 2026
@mszadkow
mszadkow marked this pull request as ready for review June 26, 2026 10:41
@kubernetes-prow kubernetes-prow Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 26, 2026
@kubernetes-prow
kubernetes-prow Bot requested review from kshalot and mbobrovskyi June 26, 2026 10:41

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/scheduler/flavorassigner/tas_flavorassigner.go`:
- Around line 160-175: The TAS flavor inference in inferTASFlavorFromPodSetGroup
is order-dependent because it returns the first same-group peer with a single
TAS flavor. Update the peer scan in tas_flavorassigner.go to validate all
eligible peers in the PodSetGroup before choosing a flavor, and reject the group
when peers resolve to different TAS flavors instead of inheriting whichever peer
appears first in wl.Obj.Spec.PodSets. Use the existing podSetAssignmentByName
and onlyTASFlavor flow to detect conflicting peer flavors and surface the
ambiguity as an error.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 16f66805-b5d3-4864-bbb5-19b50fe841e6

📥 Commits

Reviewing files that changed from the base of the PR and between 99e5ae3 and a09781c.

📒 Files selected for processing (2)
  • pkg/scheduler/flavorassigner/flavorassigner_test.go
  • pkg/scheduler/flavorassigner/tas_flavorassigner.go

Comment thread pkg/scheduler/flavorassigner/tas_flavorassigner.go Outdated
@mszadkow
mszadkow force-pushed the fix/12417-lws-leader-with-no-request branch from a09781c to 86e8c55 Compare June 27, 2026 07:56

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/scheduler/flavorassigner/tas_flavorassigner.go`:
- Around line 176-183: Exclude Count=0 peers from TAS flavor inference in
tas_flavorassigner.go. Update the peer iteration in the TAS flavor assigner
logic so only active PodSets are considered, matching WorkloadsTopologyRequests
behavior and avoiding inference from inactive peers. Use the existing peer
assignment flow around podSetAssignmentByName, onlyTASFlavor, and the
peerPodSet/peerAssignment checks to filter out peers whose PodSet Count is zero
before attempting flavor inference or conflict detection.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: adedf234-ecda-45cf-add8-b46094e70dbe

📥 Commits

Reviewing files that changed from the base of the PR and between a09781c and 86e8c55.

📒 Files selected for processing (2)
  • pkg/scheduler/flavorassigner/flavorassigner_test.go
  • pkg/scheduler/flavorassigner/tas_flavorassigner.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/scheduler/flavorassigner/flavorassigner_test.go

Comment thread pkg/scheduler/flavorassigner/tas_flavorassigner.go Outdated
@mszadkow
mszadkow force-pushed the fix/12417-lws-leader-with-no-request branch 2 times, most recently from fd3e433 to 9f8673b Compare June 27, 2026 08:12

@j-skiba j-skiba 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 think this fix exposes another issue here

return ptr.Deref(result, 0), limitingResource

as r will be empty then the returned result will be equal to 0.

Maybe let's add an integration test for that

Comment thread pkg/scheduler/flavorassigner/tas_flavorassigner.go Outdated
Comment thread pkg/scheduler/flavorassigner/tas_flavorassigner.go Outdated
@mimowo

mimowo commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

/hold
cc @dkaluza ptal

@kubernetes-prow kubernetes-prow Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 29, 2026

@dkaluza dkaluza 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.

For now I have reviewed the tests, I will try to review the rest tomorrow.

Comment thread pkg/scheduler/flavorassigner/flavorassigner_test.go Outdated
Comment thread pkg/scheduler/flavorassigner/flavorassigner_test.go Outdated
Comment thread pkg/scheduler/flavorassigner/flavorassigner_test.go Outdated
Comment thread pkg/scheduler/flavorassigner/flavorassigner_test.go Outdated
Comment thread pkg/scheduler/flavorassigner/flavorassigner_test.go Outdated
Comment thread pkg/scheduler/flavorassigner/tas_flavorassigner.go Outdated

@dkaluza dkaluza 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.

Went through the rest of code. I'm generally a little worried about the complexity of this code and the fact that by it we are probably only covering a single edge case - when peer podset has an assignment. As mentioned in the original issue, there might be also other edge cases that we should probably think about (e.g. what if there are no peers at all?)

In my opinion we should investigate the root cause, why none of the flavors was assigned to this podset and try to improve there. For example if this is cause because we always require a resource in this assignment maybe it would be a good idea to create an artificial resource entry in the assignment to just handle those in more systematic manner (remark I do not know if this is viable, one should investigate).

Comment thread pkg/scheduler/flavorassigner/tas_flavorassigner.go Outdated
Comment thread pkg/scheduler/flavorassigner/tas_flavorassigner.go Outdated
Comment thread pkg/scheduler/flavorassigner/tas_flavorassigner.go Outdated
Comment thread pkg/scheduler/flavorassigner/tas_flavorassigner.go Outdated
@mszadkow
mszadkow force-pushed the fix/12417-lws-leader-with-no-request branch from 9f8673b to 02b93ee Compare July 1, 2026 16:34
@kubernetes-prow kubernetes-prow Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 3, 2026
Comment thread pkg/scheduler/flavorassigner/flavorassigner.go Outdated
@mszadkow
mszadkow force-pushed the fix/12417-lws-leader-with-no-request branch from 081373e to 9223e5f Compare August 3, 2026 16:49
Comment on lines +868 to +880
// For PodSets with requests, keep only flavors for resources this PodSet requests.
var reqKeys []corev1.ResourceName
idxPodSet.podSet.Requests.ForEach(func(name corev1.ResourceName, _ int64) {
reqKeys = append(reqKeys, name)
})
podSetFlavors := utilmaps.FilterKeys(groupFlavors, reqKeys)
if idxPodSet.podSet.Requests.Len() != 0 {
log.V(5).Info("Resolved PodSet flavors from group flavors",
"podSet", idxPodSet.podSet.Name,
"requestedResources", idxPodSet.podSet.Requests.Len(),
"resolvedFlavors", len(podSetFlavors))
return podSetFlavors
}

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.

Suggested change
// For PodSets with requests, keep only flavors for resources this PodSet requests.
var reqKeys []corev1.ResourceName
idxPodSet.podSet.Requests.ForEach(func(name corev1.ResourceName, _ int64) {
reqKeys = append(reqKeys, name)
})
podSetFlavors := utilmaps.FilterKeys(groupFlavors, reqKeys)
if idxPodSet.podSet.Requests.Len() != 0 {
log.V(5).Info("Resolved PodSet flavors from group flavors",
"podSet", idxPodSet.podSet.Name,
"requestedResources", idxPodSet.podSet.Requests.Len(),
"resolvedFlavors", len(podSetFlavors))
return podSetFlavors
}
if idxPodSet.podSet.Requests.Len() != 0 {
// For PodSets with requests, keep only flavors for resources this PodSet requests.
var reqKeys []corev1.ResourceName
idxPodSet.podSet.Requests.ForEach(func(name corev1.ResourceName, _ int64) {
reqKeys = append(reqKeys, name)
})
podSetFlavors := utilmaps.FilterKeys(groupFlavors, reqKeys)
log.V(5).Info("Resolved PodSet flavors from group flavors",
"podSet", idxPodSet.podSet.Name,
"requestedResources", idxPodSet.podSet.Requests.Len(),
"resolvedFlavors", len(podSetFlavors))
return podSetFlavors
}

I might be missing something, but why not just like this, scoping reqKeys to where it is needed?

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 have followed your suggestion while slightly changing it

Comment thread pkg/scheduler/flavorassigner/flavorassigner.go
@mszadkow
mszadkow force-pushed the fix/12417-lws-leader-with-no-request branch from 9223e5f to d0c2735 Compare August 4, 2026 08:50

@dkaluza dkaluza 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.

Please update the PR description as we no longer assign the single flavor from the CQ

@dkaluza dkaluza 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.

Code LGTM, just nitpick to fix a comment

Comment thread pkg/scheduler/flavorassigner/flavorassigner_test.go Outdated
@mszadkow
mszadkow force-pushed the fix/12417-lws-leader-with-no-request branch from d0c2735 to cd4cd15 Compare August 4, 2026 20:43

@mimowo mimowo 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
/approve
/cherrypick release-0.19
/cherrypick release-0.18
Thank you for the fix 👍

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 4, 2026
@kubernetes-prow

Copy link
Copy Markdown

LGTM label has been added.

DetailsGit tree hash: 8b69141861e469db3493157fbefbd252dad22576

@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dkaluza, mimowo, mszadkow

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

The pull request process is described 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

@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 4, 2026
@kubernetes-prow
kubernetes-prow Bot merged commit b5913ca into kubernetes-sigs:main Aug 4, 2026
56 checks passed
@kubernetes-prow kubernetes-prow Bot added this to the v0.20 milestone Aug 4, 2026
@mimowo

mimowo commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

/cherrypick release-0.19
/cherrypick release-0.18

@mimowo

mimowo commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

@mszadkow please prepare the CPs if the robot fails

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown
Contributor

@mimowo: new pull request created: #13849

Details

In response to this:

/cherrypick release-0.19
/cherrypick release-0.18

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-infra-cherrypick-robot

Copy link
Copy Markdown
Contributor

@mimowo: new pull request created: #13850

Details

In response to this:

/cherrypick release-0.19
/cherrypick release-0.18

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.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/integrations Workload integrations area/tas Topology-Aware Scheduling cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. kind/regression Categorizes issue or PR as related to a regression from a prior release. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

LWS podset TAS regression since v0.17.5 when leader does not request resources managed by CQ

7 participants