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

Support Preemption while borrowing #1397

Merged
merged 5 commits into from Jan 5, 2024

Conversation

mimowo
Copy link
Contributor

@mimowo mimowo commented Dec 4, 2023

What type of PR is this?

/kind feature

What this PR does / why we need it:

Which issue(s) this PR fixes:

Part of #1337

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Support for preemption while borrowing

@k8s-ci-robot k8s-ci-robot 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/feature Categorizes issue or PR as related to a new feature. labels Dec 4, 2023
Copy link

netlify bot commented Dec 4, 2023

Deploy Preview for kubernetes-sigs-kueue canceled.

Name Link
🔨 Latest commit 5b2ec29
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-kueue/deploys/659837f7fcd6870008b8b110

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 4, 2023
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 4, 2023
@mimowo mimowo force-pushed the preemption-with-borrowing branch 5 times, most recently from d318009 to fcba607 Compare December 5, 2023 13:08
@mimowo mimowo changed the title [WIP]: Preemption with borrowing [WIP]: Preemption while borrowing Dec 6, 2023
@mimowo mimowo force-pushed the preemption-with-borrowing branch 2 times, most recently from 1def45b to 73626b0 Compare December 6, 2023 15:23
@mimowo mimowo force-pushed the preemption-with-borrowing branch 7 times, most recently from 23332e0 to c54df4e Compare December 15, 2023 14:58
@mimowo
Copy link
Contributor Author

mimowo commented Dec 15, 2023

/test pull-kueue-test-integration-main

@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 Dec 18, 2023
@mimowo mimowo force-pushed the preemption-with-borrowing branch 4 times, most recently from 67a8bce to 9eb1cd1 Compare December 18, 2023 12:19
@mimowo mimowo force-pushed the preemption-with-borrowing branch 5 times, most recently from 287cf0d to e04ed60 Compare January 4, 2024 16:58
apis/kueue/v1beta1/clusterqueue_types.go Show resolved Hide resolved
pkg/scheduler/flavorassigner/flavorassigner.go Outdated Show resolved Hide resolved
pkg/scheduler/preemption/preemption.go Outdated Show resolved Hide resolved
pkg/scheduler/preemption/preemption.go Outdated Show resolved Hide resolved
@mimowo mimowo force-pushed the preemption-with-borrowing branch 3 times, most recently from 7915368 to f4d79cf Compare January 5, 2024 13:54
if cq.Preemption.BorrowWithinCohort != nil && cq.Preemption.BorrowWithinCohort.Policy != kueue.BorrowWithinCohortPolicyNever {
// when preemption with borrowing is enabled, we can succeeded admitting the
// workload if preemption is used.
if (rQuota.BorrowingLimit == nil || rQuota.BorrowingLimit != nil && val <= rQuota.Nominal+*rQuota.BorrowingLimit) && val <= cohortAvailable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (rQuota.BorrowingLimit == nil || rQuota.BorrowingLimit != nil && val <= rQuota.Nominal+*rQuota.BorrowingLimit) && val <= cohortAvailable {
if (rQuota.BorrowingLimit == nil || val <= rQuota.Nominal+*rQuota.BorrowingLimit) && val <= cohortAvailable {

pkg/scheduler/preemption/preemption.go Outdated Show resolved Hide resolved
pkg/scheduler/preemption/preemption.go Show resolved Hide resolved
// to priorities (from lowest to highest, using candidatesOrdering),
// and the last added target is not removed in the second phase of
// the function.
allowBorrowing = false
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm no longer sure if this works.

What if, in a previous iteration, we were already borrowing? Then workloadFits would return false and break this loop. So far so good.

However, the next loop (check if any of the workloads can be added back) would be prevented from borrowing, even though it was ok to borrow. As a result, we won't be able to add back any workload, possibly leading to preempting more workloads than necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What if, in a previous iteration, we were already borrowing? Then workloadFits would return false and break this loop. So far so good.

The workloadFits breaks when returning true (not false), snippet from below:

		if workloadFits(wlReq, cq, allowBorrowing) {
			fits = true
			break
		}

Copy link
Contributor

Choose a reason for hiding this comment

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

ohhhh, right.

So the mechanics roughly like this:

  1. allowBorrowing=true, workload doesn't fit,
  2. we pass the threshold, workload still doesn't fit, we can continue deleting workloads, but now we cannot allow borrowing.
  3. Eventually, the workload fits. We are already deleting workloads past the threshold, so if we put workloads back, we cannot allow borrowing anyway.

Ack.

@alculquicondor
Copy link
Contributor

/lgtm
/approve

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

LGTM label has been added.

Git tree hash: 8c988c2cf685a17850d5e3d9efa0cc27f8a24529

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alculquicondor, mimowo

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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 5, 2024
@k8s-ci-robot k8s-ci-robot merged commit 5c38cdd into kubernetes-sigs:main Jan 5, 2024
14 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v0.6 milestone Jan 5, 2024
@mimowo mimowo deleted the preemption-with-borrowing branch February 10, 2024 11:48
@tenzen-y
Copy link
Member

/kind api-change

@k8s-ci-robot k8s-ci-robot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Feb 12, 2024
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/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. 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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants