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

[Cache] Sort resourceUsages according to resourceName #907

Merged
merged 1 commit into from
Jun 27, 2023

Conversation

tenzen-y
Copy link
Member

What type of PR is this?

/kind bug

What this PR does / why we need it:

The resourceUsages should be in a stable order to avoid endless creation of update events.
So, I added processes to sort resourceUsages according to resourceName in ClusterQueue and LocalQueue.

Which issue(s) this PR fixes:

Fixes #902

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Fix a bug that updates events for clusterQueues are created endlessly.

@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 Jun 27, 2023
@netlify
Copy link

netlify bot commented Jun 27, 2023

Deploy Preview for kubernetes-sigs-kueue canceled.

Name Link
🔨 Latest commit 7131a1c
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-kueue/deploys/649b22772a1c3e00087b88e3

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 27, 2023
Comment on lines 1490 to 1492
if diff := cmp.Diff(tc.wantUsedResources, resources); diff != "" {
t.Errorf("Unexpected used resources (-want,+got):\n%s", diff)
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Before I added sort, this tests failed:

$ go test -run 'TestClusterQueueUsage' ./pkg/cache/...
go: downloading k8s.io/apiextensions-apiserver v0.26.6
--- FAIL: TestClusterQueueUsage (0.01s)
    --- FAIL: TestClusterQueueUsage/clusterQueue_without_cohort;_single_no_borrowing (0.01s)
        cache_test.go:1490: Unexpected used resources (-want,+got):
              []v1beta1.FlavorUsage{
                {Name: "default", Resources: {{Name: s"cpu", Total: {i: {...}, Format: "DecimalSI"}}}},
                {Name: "model_a", Resources: {{Name: s"example.com/gpu", Total: {i: {...}, Format: "DecimalSI"}}}},
                {Name: "model_b", Resources: {{Name: s"example.com/gpu"}}},
                {
                        Name: "interconnect_a",
                        Resources: []v1beta1.ResourceUsage{
            +                   {Name: s"example.com/vf-2", Total: resource.Quantity{Format: "DecimalSI"}},
                                {Name: s"example.com/vf-0"},
                                {Name: s"example.com/vf-1"},
            -                   {Name: s"example.com/vf-2"},
                        },
                },
              }
        cache_test.go:1490: Unexpected used resources (-want,+got):
              []v1beta1.FlavorUsage{
                {Name: "default", Resources: {{Name: s"cpu", Total: {i: {...}, Format: "DecimalSI"}}}},
                {Name: "model_a", Resources: {{Name: s"example.com/gpu", Total: {i: {...}, Format: "DecimalSI"}}}},
                {Name: "model_b", Resources: {{Name: s"example.com/gpu"}}},
                {
                        Name: "interconnect_a",
                        Resources: []v1beta1.ResourceUsage{
            -                   {Name: s"example.com/vf-0"},
                                {Name: s"example.com/vf-1"},
                                {Name: s"example.com/vf-2"},
            +                   {Name: s"example.com/vf-0", Total: resource.Quantity{Format: "DecimalSI"}},
                        },
                },
              }
        cache_test.go:1490: Unexpected used resources (-want,+got):
              []v1beta1.FlavorUsage{
                {Name: "default", Resources: {{Name: s"cpu", Total: {i: {...}, Format: "DecimalSI"}}}},
                {Name: "model_a", Resources: {{Name: s"example.com/gpu", Total: {i: {...}, Format: "DecimalSI"}}}},
                {Name: "model_b", Resources: {{Name: s"example.com/gpu"}}},
                {
                        Name: "interconnect_a",
                        Resources: []v1beta1.ResourceUsage{
            +                   {Name: s"example.com/vf-2", Total: resource.Quantity{Format: "DecimalSI"}},
                                {Name: s"example.com/vf-0"},
                                {Name: s"example.com/vf-1"},
            -                   {Name: s"example.com/vf-2"},
                        },
                },
              }
    --- FAIL: TestClusterQueueUsage/clusterQueue_with_cohort;_multiple_borrowing (0.00s)
        cache_test.go:1490: Unexpected used resources (-want,+got):
              []v1beta1.FlavorUsage{
                {Name: "default", Resources: {{Name: s"cpu", Total: {i: {...}, Format: "DecimalSI"}, Borrowed: {i: {...}, Format: "DecimalSI"}}}},
                {Name: "model_a", Resources: {{Name: s"example.com/gpu", Total: {i: {...}, Format: "DecimalSI"}}}},
                {Name: "model_b", Resources: {{Name: s"example.com/gpu", Total: {i: {...}, Format: "DecimalSI"}, Borrowed: {i: {...}, Format: "DecimalSI"}}}},
                {
                        Name: "interconnect_a",
                        Resources: []v1beta1.ResourceUsage{
            -                   {Name: s"example.com/vf-0"},
                                {Name: s"example.com/vf-1"},
                                {Name: s"example.com/vf-2"},
            +                   {Name: s"example.com/vf-0", Total: resource.Quantity{Format: "DecimalSI"}},
                        },
                },
              }
        cache_test.go:1490: Unexpected used resources (-want,+got):
              []v1beta1.FlavorUsage{
                {Name: "default", Resources: {{Name: s"cpu", Total: {i: {...}, Format: "DecimalSI"}, Borrowed: {i: {...}, Format: "DecimalSI"}}}},
                {Name: "model_a", Resources: {{Name: s"example.com/gpu", Total: {i: {...}, Format: "DecimalSI"}}}},
                {Name: "model_b", Resources: {{Name: s"example.com/gpu", Total: {i: {...}, Format: "DecimalSI"}, Borrowed: {i: {...}, Format: "DecimalSI"}}}},
                {
                        Name: "interconnect_a",
                        Resources: []v1beta1.ResourceUsage{
            +                   {Name: s"example.com/vf-2", Total: resource.Quantity{Format: "DecimalSI"}},
                                {Name: s"example.com/vf-0"},
                                {Name: s"example.com/vf-1"},
            -                   {Name: s"example.com/vf-2"},
                        },
                },
              }
    --- FAIL: TestClusterQueueUsage/clusterQueue_without_cohort;_multiple_borrowing (0.00s)
        cache_test.go:1490: Unexpected used resources (-want,+got):
              []v1beta1.FlavorUsage{
                {Name: "default", Resources: {{Name: s"cpu", Total: {i: {...}, Format: "DecimalSI"}}}},
                {Name: "model_a", Resources: {{Name: s"example.com/gpu", Total: {i: {...}, Format: "DecimalSI"}}}},
                {Name: "model_b", Resources: {{Name: s"example.com/gpu", Total: {i: {...}, Format: "DecimalSI"}}}},
                {
                        Name: "interconnect_a",
                        Resources: []v1beta1.ResourceUsage{
            +                   {Name: s"example.com/vf-2", Total: resource.Quantity{Format: "DecimalSI"}},
                                {Name: s"example.com/vf-0"},
                                {Name: s"example.com/vf-1"},
            -                   {Name: s"example.com/vf-2"},
                        },
                },
              }
FAIL
FAIL    sigs.k8s.io/kueue/pkg/cache     0.640s
FAIL

@tenzen-y
Copy link
Member Author

/assign @alculquicondor

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
I would just remove the loops

pkg/cache/cache_test.go Outdated Show resolved Hide resolved
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alculquicondor, tenzen-y

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 27, 2023
Signed-off-by: Yuki Iwai <yuki.iwai.tz@gmail.com>
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 27, 2023
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.

/lgtm

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

let's cherry-pick as well.
I think we can do a last patch release of 0.3 along with 0.4

@tenzen-y
Copy link
Member Author

let's cherry-pick as well.
I think we can do a last patch release of 0.3 along with 0.4

That's great!

/cherrypick release-0.3

@k8s-infra-cherrypick-robot

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

In response to this:

let's cherry-pick as well.
I think we can do a last patch release of 0.3 along with 0.4

That's great!

/cherrypick release-0.3

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.

@k8s-ci-robot k8s-ci-robot merged commit bef96eb into kubernetes-sigs:main Jun 27, 2023
15 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v0.4 milestone Jun 27, 2023
@k8s-infra-cherrypick-robot

@tenzen-y: #907 failed to apply on top of branch "release-0.3":

Applying: Sort resourceUsages according to resourceName
Using index info to reconstruct a base tree...
M	pkg/cache/cache.go
M	pkg/cache/cache_test.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/cache/cache_test.go
CONFLICT (content): Merge conflict in pkg/cache/cache_test.go
Auto-merging pkg/cache/cache.go
CONFLICT (content): Merge conflict in pkg/cache/cache.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Sort resourceUsages according to resourceName
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

let's cherry-pick as well.
I think we can do a last patch release of 0.3 along with 0.4

That's great!

/cherrypick release-0.3

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.

@tenzen-y tenzen-y deleted the sort-usage-resources branch June 27, 2023 18:17
k8s-ci-robot added a commit that referenced this pull request Jun 27, 2023
…pstream-release-0.3

Automated cherry pick of #907: Sort resourceUsages according to resourceName
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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ClusterQueue update events continue to fire forever
4 participants