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

Use Kueue API types in FlavorAssignerTest #2486

Merged

Conversation

gabesaba
Copy link
Contributor

@gabesaba gabesaba commented Jun 27, 2024

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

We update the FlavorAssignerTest to use Kueue API types, rather than construct CQ/Cohort snapshot manually. This will allow us to change CQ/Cohort Snapshot logic without updating the tests each time.

Preparation for main changes in #79

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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Jun 27, 2024
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jun 27, 2024
Copy link

netlify bot commented Jun 27, 2024

Deploy Preview for kubernetes-sigs-kueue canceled.

Name Link
🔨 Latest commit 005c37f
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-kueue/deploys/6683e70109167b00070f0c83

@gabesaba
Copy link
Contributor Author

@macsko

}.Unflatten(),
},
requestableResources: resources.FlavorResourceQuantitiesFlat{
{Flavor: "one", Resource: corev1.ResourceCPU}: 2000,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note to reviewers: This test started failing once borrowing limit was added (limitation of the Resource constructor - which requires you to specify borrowing limit to set lending limit)

I think the original test didn't match its intention: since previously there was no borrowing limit, the cq wasn't looking for capacity in its cohort, only looking in cq. I changed this value to 2000m, and specified 10000m borrowing limit.

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 not convinced, if there is no borrowing limit, then the cq is free to borrow within the entire cq.
Would it be feasible to have a new dedicated constructor to let using borrowingLimit =0, so that we are sure we don't drop some coverage?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1. nil borrowingLimit means "borrow any amount". Please revert numbers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, my explaination was wrong, but the test was still broken. See explaination here #2486 (comment)

Copy link
Contributor

@macsko macsko left a comment

Choose a reason for hiding this comment

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

Looks good, two small comments

pkg/scheduler/flavorassigner/flavorassigner_test.go Outdated Show resolved Hide resolved
pkg/scheduler/flavorassigner/flavorassigner_test.go Outdated Show resolved Hide resolved
@gabesaba gabesaba force-pushed the refactor_flavor_resource_test branch from 9ecf0a4 to ba89f13 Compare June 27, 2024 15:12
@gabesaba
Copy link
Contributor Author

Looks good, two small comments

thanks for the review

@@ -2373,6 +1993,19 @@ func TestAssignFlavors(t *testing.T) {
}
}

func updateResources(dest resources.FlavorResourceQuantities, src resources.FlavorResourceQuantitiesFlat) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use the pre-existing Unflatten function for this, like clusterQueue.Usage = tc.clusterQueueUsage.Unflatten()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could do this in all but one case - a test breaks unfortunately. But I don't like this approach either. We should clean this up in a future PR - by calling some public method of cache or snapshot to get the values we want, rather than manipulating the internal accounting of the CQs/Cohorts

Created #2502

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, was able to get rid of guaranteedQuota, as this value is now updated in cache logic.

ResourceGroup(
utiltesting.MakeFlavorQuotas("one").
Resource(corev1.ResourcePods, "10").
Resource(corev1.ResourceCPU, "10000m", "1000", "1000m").
Copy link
Contributor

@mimowo mimowo Jun 28, 2024

Choose a reason for hiding this comment

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

This borrowing limit "1000" looks suspicious, IIUC it is unbound in the deleted code, which is slightly different semantically, Would there be a way to express "unbound" now? Otherwise maybe Max int 32, but this may mean that we no longer cover cases when borrowingLimit==nil. (same question for some test cases below)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated the tests to match original semantics

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.

Thanks, nice preparatory pr which will make the following PRs easier to review!

@mimowo
Copy link
Contributor

mimowo commented Jun 28, 2024

/lgtm
/approve
/hold
in case @alculquicondor wants to give a pass

@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 Jun 28, 2024
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 28, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: d4dd3ceb413f316b130f7d4714b22633bd9853a0

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gabesaba, 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 Jun 28, 2024
pkg/scheduler/flavorassigner/flavorassigner_test.go Outdated Show resolved Hide resolved
pkg/scheduler/flavorassigner/flavorassigner_test.go Outdated Show resolved Hide resolved
pkg/util/testing/wrappers.go Outdated Show resolved Hide resolved
}.Unflatten(),
},
requestableResources: resources.FlavorResourceQuantitiesFlat{
{Flavor: "one", Resource: corev1.ResourceCPU}: 2000,
Copy link
Contributor

Choose a reason for hiding this comment

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

+1. nil borrowingLimit means "borrow any amount". Please revert numbers.

pkg/scheduler/flavorassigner/flavorassigner_test.go Outdated Show resolved Hide resolved
wlReclaimablePods []kueue.ReclaimablePod
clusterQueue kueue.ClusterQueue
clusterQueueUsage resources.FlavorResourceQuantitiesFlat
clusterQueueGuaranteedQuota resources.FlavorResourceQuantitiesFlat
Copy link
Contributor

Choose a reason for hiding this comment

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

this should not be necessary. It should be calculated by the cache logic based on the lendingLimit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

after removal, a bunch of tests fail. we can clean up in #2502

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe some tests didn't put the right LendingLimit.
Ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was able to remove guaranteedQuota; I'm not sure what was happening last week (unless I thought you were referring to a different field?)

@gabesaba gabesaba force-pushed the refactor_flavor_resource_test branch from 2917889 to 9f0b496 Compare June 28, 2024 16:57
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 28, 2024
@k8s-ci-robot k8s-ci-robot requested a review from mimowo June 28, 2024 16:57
{Flavor: "one", Resource: corev1.ResourceCPU}: 2_000,
},
requestableResources: resources.FlavorResourceQuantitiesFlat{
{Flavor: "one", Resource: corev1.ResourceCPU}: 2_000,
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this was 10_000 before

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test was previously broken/didn't make sense, as it set up the internal state incorrectly. With a lending limit of 0, it should have also set guaranteed quota to 10. I made the minimal update to make it work again. After my change to use the cache, it was failing as the workload actually fit.

I am going to rename, by s/lendinglimit/quota//

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 pretty sure this test was added when the lendingLimit feature was added. So we are probably missing some coverage on it now. @kerthcet do you recall what was the intention of the test and can you send a PR to fix it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll take a look later. Thanks for reminding, almost missed it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I couldn't find the case, can anyone point that out?

Copy link
Contributor

Choose a reason for hiding this comment

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

image

@gabesaba gabesaba force-pushed the refactor_flavor_resource_test branch from 9f0b496 to d9a5e72 Compare July 2, 2024 10:36
@mimowo
Copy link
Contributor

mimowo commented Jul 2, 2024

LGTM, just one nit to rename the test

@gabesaba gabesaba force-pushed the refactor_flavor_resource_test branch from d9a5e72 to 005c37f Compare July 2, 2024 11:39
@gabesaba
Copy link
Contributor Author

gabesaba commented Jul 2, 2024

LGTM, just one nit to rename the test

Done. Thanks for the review!

@mimowo
Copy link
Contributor

mimowo commented Jul 2, 2024

/lgtm

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

LGTM label has been added.

Git tree hash: cc59312abc3a5ed7512193dcc10f8fc4bbc5ca0e

@mimowo
Copy link
Contributor

mimowo commented Jul 2, 2024

/hold cancel
I think we are good to merge as all comments are addressed. We can follow up in case @alculquicondor has another comment.

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 2, 2024
@k8s-ci-robot k8s-ci-robot merged commit 8f3bfcb into kubernetes-sigs:main Jul 2, 2024
16 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v0.8 milestone Jul 2, 2024
@gabesaba gabesaba deleted the refactor_flavor_resource_test branch July 9, 2024 15:49
kannon92 pushed a commit to openshift-kannon92/kubernetes-sigs-kueue that referenced this pull request Nov 19, 2024
* Define ResourceQuotaWrapper; improve documentation

* Update FlavorAssignerTest to use ClusterQueue API types

* Add tests for deleted flavor

* Improve readability of test quantities
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants