Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fungibility: Try next flavor if can't preempt on first #1366

Merged
merged 2 commits into from Nov 27, 2023

Conversation

alculquicondor
Copy link
Contributor

@alculquicondor alculquicondor commented Nov 24, 2023

What type of PR is this?

/kind bug

What this PR does / why we need it:

This PR fixes 3 problems:

  • The AllocatableResourceGeneration for a ClusterQueue was changing for unrelated status updates (Thanks to @KunWuLuan for this fix)
  • Needed to requeue immediately if there are pending flavors to try.
  • The indexes for the lastattempt were accumulating across scheduling attempts.

Which issue(s) this PR fixes:

Fixes #1344

Special notes for your reviewer:

This supersedes #1356.

I want to add more tests before merging.

Does this PR introduce a user-facing change?

Fix fungibility policy `Preempt` where it was not able to utilize the next flavor if preemption was not possible.

@k8s-ci-robot k8s-ci-robot added 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. labels Nov 24, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alculquicondor

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

The pull request process is described here

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

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 24, 2023
Copy link

netlify bot commented Nov 24, 2023

Deploy Preview for kubernetes-sigs-kueue canceled.

Name Link
🔨 Latest commit 7dbbe8d
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-kueue/deploys/6564f999d6292100080099f1

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 24, 2023
@alculquicondor
Copy link
Contributor Author

/hold
I want to add a few unit tests.

@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 Nov 24, 2023
@alculquicondor alculquicondor force-pushed the KunWuLuan/main branch 2 times, most recently from 72e6f77 to e7115a3 Compare November 24, 2023 21:15
@tenzen-y
Copy link
Member

/label tide/merge-method-merge

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-merge Denotes a PR that should use a standard merge by tide when it merges. label Nov 27, 2023
Copy link
Member

@tenzen-y tenzen-y left a comment

Choose a reason for hiding this comment

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

/lgtm

I left just a question.

Comment on lines 260 to 272
if lastAssignment != nil {
assignment.LastState = *lastAssignment
} else {
assignment.LastState = workload.AssigmentClusterQueueState{
LastState: workload.AssigmentClusterQueueState{
Copy link
Member

Choose a reason for hiding this comment

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

Why don't we set the lastAssignment to the assignment.LastState when the lastAssignment isn't nil?
IIUC, we can use the lastAssignment since the lastAssignment is the latest, not outdated here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed we are using it, but directly from the variable lastAssigment, not assignment.LastState.

The problem with not clearing it is that assignment.append (line 324) keeps adding indexes to the slice of indexes.

Copy link
Member

Choose a reason for hiding this comment

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

I see. That makes sense.
This is just a confirmation, with this change, the scheduler will try all flavors every scheduling and the scheduler's performance will be slightly lower, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are still using the values of lastAssigment to skip flavors that were already tried. So basically the logic here was not necessary.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see. It makes sense. Thanks

@@ -142,7 +142,7 @@ func (c *clusterQueueBase) requeueIfNotPresent(wInfo *workload.Info, immediate b
c.rwm.Lock()
defer c.rwm.Unlock()
key := workload.Key(wInfo.Obj)
if immediate || c.queueInadmissibleCycle >= c.popCycle {
if immediate || c.queueInadmissibleCycle >= c.popCycle || wInfo.LastAssignment.PendingFlavors() {
Copy link
Member

Choose a reason for hiding this comment

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

Oh, this fix is great to see. I couldn't find this hidden bug.

pkg/scheduler/scheduler_test.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 27, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 748c53c3b37b67962ea8a6c173a31e0538c2f05e

@tenzen-y tenzen-y mentioned this pull request Nov 27, 2023
21 tasks
@tenzen-y
Copy link
Member

/cherry-pick release-0.5

@k8s-infra-cherrypick-robot

@tenzen-y: once the present PR merges, I will cherry-pick it on top of release-0.5 in a new PR and assign it to you.

In response to this:

/cherry-pick release-0.5

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/test-infra repository.

@alculquicondor
Copy link
Contributor Author

/hold
I want to add more tests before merging. Just to make sure there aren't more surprises.

@alculquicondor
Copy link
Contributor Author

/hold cancel
I added the tests I wanted to add :)

Copy link
Member

@tenzen-y tenzen-y left a comment

Choose a reason for hiding this comment

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

Thanks!

/lgtm

Comment on lines 260 to 272
if lastAssignment != nil {
assignment.LastState = *lastAssignment
} else {
assignment.LastState = workload.AssigmentClusterQueueState{
LastState: workload.AssigmentClusterQueueState{
Copy link
Member

Choose a reason for hiding this comment

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

I see. That makes sense.
This is just a confirmation, with this change, the scheduler will try all flavors every scheduling and the scheduler's performance will be slightly lower, right?

@k8s-ci-robot k8s-ci-robot removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Nov 27, 2023
@tenzen-y
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 27, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 66c521fe6e32036d6e8c549e0eb563b2e891731f

@k8s-ci-robot k8s-ci-robot merged commit 7867957 into kubernetes-sigs:main Nov 27, 2023
14 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v0.6 milestone Nov 27, 2023
@k8s-infra-cherrypick-robot

@tenzen-y: new pull request created: #1370

In response to this:

/cherry-pick release-0.5

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/test-infra repository.

@KunWuLuan
Copy link
Contributor

Thanks for your help 👍

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. 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. tide/merge-method-merge Denotes a PR that should use a standard merge by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ClusterQueue not considering next ResourceFlavor when whenCanPreempt: Preempt is set
5 participants