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

Add comments to explain special cases #1496

Merged
merged 2 commits into from
Dec 28, 2023

Conversation

kerthcet
Copy link
Contributor

@kerthcet kerthcet commented Dec 19, 2023

What type of PR is this?

/kind bug

What this PR does / why we need it:

Based on my understanding, even borrowlingLimit not nil, if cq.cohort == nil, we should still not consider the borrowingLimit in calculation. cc @alculquicondor is this a real bug or as designed?

Just for explaination.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

None

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 19, 2023
Copy link

netlify bot commented Dec 19, 2023

Deploy Preview for kubernetes-sigs-kueue canceled.

Name Link
🔨 Latest commit a6fec86
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-kueue/deploys/658cd6a09c10440008d412e7

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Dec 19, 2023
@alculquicondor
Copy link
Contributor

I agree that if the CQ doesn't belong to a cohort, the borrowingLimit should be considered 0.
Can you add a unit test case in TestPreemption that proves that there was a bug?

@kerthcet
Copy link
Contributor Author

/retest pull-kueue-test-unit-main

@k8s-ci-robot
Copy link
Contributor

@kerthcet: The /retest command does not accept any targets.
The following commands are available to trigger required jobs:

  • /test pull-kueue-build-image-main
  • /test pull-kueue-test-e2e-main-1-25
  • /test pull-kueue-test-e2e-main-1-26
  • /test pull-kueue-test-e2e-main-1-27
  • /test pull-kueue-test-e2e-main-1-28
  • /test pull-kueue-test-integration-main
  • /test pull-kueue-test-unit-main
  • /test pull-kueue-verify-main

Use /test all to run all jobs.

In response to this:

/retest pull-kueue-test-unit-main

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.

@kerthcet
Copy link
Contributor Author

/test pull-kueue-test-unit-main

@kerthcet kerthcet force-pushed the fix/workloadsFits branch 2 times, most recently from aa8cfba to dbaea07 Compare December 22, 2023 09:30
@@ -334,12 +336,15 @@ func workloadFits(wlReq cache.FlavorResourceQuantities, cq *cache.ClusterQueue,
}
for rName, rReq := range flvReq {
limit := flvQuotas.Resources[rName].Nominal
if flvQuotas.Resources[rName].BorrowingLimit != nil && allowBorrowing {

if cq.Cohort != nil && allowBorrowing && flvQuotas.Resources[rName].BorrowingLimit != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on the comment:

	// If null, it means that there is no borrowing limit.
	// If not null, it must be non-negative.
	// borrowingLimit must be null if spec.cohort is empty.
	// +optional
	BorrowingLimit *resource.Quantity `json:"borrowingLimit,omitempty"`

If borrowingLimit is nil then cohort must be nil, no bug here. However, we didn't have any validation about this, that's say we can still have cq with cohort == nil && borrowingLimit != nil.

My suggestion here: #1385 (comment), tl;dr: can we ignore this rule? cc @alculquicondor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cc @B1F030

Copy link
Contributor

@mimowo mimowo left a comment

Choose a reason for hiding this comment

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

It is a pity we don't have validation against cq.Cohort=nil and borrowingLimit!=nil.

Maybe it is still not too late to add, Kueue is still Beta API?

Anyway, if we go with the check for cq.Cohort != nil, should we also add it here?

@@ -64,7 +64,7 @@ func (p *Preemptor) OverrideApply(f func(context.Context, *kueue.Workload) error
}

func candidatesOnlyFromQueue(candidates []*workload.Info, clusterQueue string) []*workload.Info {
result := make([]*workload.Info, 0)
result := make([]*workload.Info, 0, len(candidates))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I would suggest to revert unrelated changes

Copy link
Contributor

Choose a reason for hiding this comment

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

also, all the workloads might be from a different CQ.

So it could be better to do var result []*workload.Info

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's clear here that the length wouldn't greater than len(candidates).

pkg/scheduler/preemption/preemption.go Outdated Show resolved Hide resolved
pkg/scheduler/preemption/preemption.go Outdated Show resolved Hide resolved
Signed-off-by: kerthcet <[email protected]>
@kerthcet kerthcet changed the title [WIP] Fix fitting workloads in preemption Add comments to explain special cases Dec 23, 2023
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 23, 2023
@kerthcet
Copy link
Contributor Author

As you reminded, we're beta now, we can not break the API semantics, so made it a cleanup. And will add the validations about the API. Maybe we can change that at v1beta2 if needed. PTAL @mimowo

@kerthcet
Copy link
Contributor Author

/remove-kind bug
/kind cleanup

@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed kind/bug Categorizes issue or PR as related to a bug. labels Dec 23, 2023
Signed-off-by: kerthcet <[email protected]>
@kerthcet
Copy link
Contributor Author

Next, I'll add more validations to avoid this.

@B1F030
Copy link
Member

B1F030 commented Dec 28, 2023

Next, I'll add more validations to avoid this.

I write a part of validation in webhook

Copy link
Contributor

@alculquicondor alculquicondor left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

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

LGTM label has been added.

Git tree hash: 656842d66315b72d236829a12304bfdb4fa45b12

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

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

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 Dec 28, 2023
@k8s-ci-robot k8s-ci-robot merged commit 7aff061 into kubernetes-sigs:main Dec 28, 2023
14 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v0.6 milestone Dec 28, 2023
@kerthcet kerthcet deleted the fix/workloadsFits branch December 29, 2023 02:03
kannon92 pushed a commit to openshift-kannon92/kubernetes-sigs-kueue that referenced this pull request Nov 19, 2024
* code refactor

Signed-off-by: kerthcet <[email protected]>

* fix comment

Signed-off-by: kerthcet <[email protected]>

---------

Signed-off-by: kerthcet <[email protected]>
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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants