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 Admitted Workloads Field to LocalQueueStatus #382

Merged
merged 1 commit into from
Sep 9, 2022
Merged

Add Admitted Workloads Field to LocalQueueStatus #382

merged 1 commit into from
Sep 9, 2022

Conversation

kannon92
Copy link
Contributor

@kannon92 kannon92 commented Sep 7, 2022

What type of PR is this?

/kind api-change

What this PR does / why we need it:

Add AdmittedWorkloads to LocalQueueStatus API and update it in the LocalQueueController.

Which issue(s) this PR fixes:

Fixes #259

Special notes for your reviewer:

Sorry for the silliness with opening up multiple repos. I have my laptop setup with CLA and github commits but I committed from another instance. I didn't realize that if 1 commit doesn't have my email, it will fail the check.

@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 Sep 7, 2022
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 7, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @kannon92. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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 added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 7, 2022
@alculquicondor
Copy link
Contributor

/assign

apis/kueue/v1alpha2/localqueue_types.go Outdated Show resolved Hide resolved
apis/kueue/v1alpha2/localqueue_types.go Outdated Show resolved Hide resolved
pkg/cache/cache.go Outdated Show resolved Hide resolved
pkg/cache/cache.go Outdated Show resolved Hide resolved
pkg/cache/cache.go Outdated Show resolved Hide resolved
pkg/cache/cache.go Show resolved Hide resolved
pkg/cache/cache_test.go Outdated Show resolved Hide resolved
pkg/cache/cache_test.go Outdated Show resolved Hide resolved
pkg/cache/cache_test.go Outdated Show resolved Hide resolved
@@ -84,6 +84,13 @@ func (r *LocalQueueReconciler) Reconcile(ctx context.Context, req ctrl.Request)
}

queueObj.Status.PendingWorkloads = pending
admitted, errAdmitted := r.cache.AdmittedWorkloadsLocalQueue(&queueObj)
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good, but this needs to be tested.

You can add checks to the existing integration tests in test/integration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! I was having some trouble running those on my setup.

I had some failures in unrelated code and some stuff to do with certs. I'll look more into it and add some tests in test/integration also.

Copy link
Contributor

Choose a reason for hiding this comment

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

Did you try make test-integration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, I'll try it again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright. There is a regression caused by this code so I'll look into it, fix it and add some tests here.

I am unable to run make test-integration on my Mac M1. it says architecture not supported and then fails every test.

I get failures when I get a test failure but it seems to be caused by the controller test detecting an error.

Copy link
Member

Choose a reason for hiding this comment

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

@kannon92 Hi.
We will fix make test-integration for M1 Mac in #362. If you want to run test-integration on your local now, please check this comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tenzen-y Thank you for that suggestion! Applied that fix locally and I was able to deduce where my test failure was. Pushed up a fix for that.

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 looks like existing tests in the controller do verify status so I just added a new field for AdmittedWorkloads in the test. I think this is fine.

@kannon92 kannon92 requested review from alculquicondor and removed request for ahg-g September 8, 2022 21:33
apis/kueue/v1alpha2/localqueue_types.go Outdated Show resolved Hide resolved
pkg/cache/cache.go Outdated Show resolved Hide resolved
pkg/cache/cache_test.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 8, 2022
pkg/cache/cache_test.go Outdated Show resolved Hide resolved
pkg/cache/cache_test.go Outdated Show resolved Hide resolved
Comment on lines 1462 to 1464
if diff := cmp.Diff(tc.wantQueueCounts[key], queueAdmitted); diff != "" {
t.Errorf("Wrong active workload counters for queues from AdmittedWorkloadsLocalQueue:\n%s", diff)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You can either do a single comparison after the loop ends, or you can add the key somewhere in the Error message. Otherwise we can't tell which queue counters didn't match

@alculquicondor
Copy link
Contributor

Please fix the latest comment and squash

@@ -148,6 +148,17 @@ func (c *Cache) newClusterQueue(cq *kueue.ClusterQueue) (*ClusterQueue, error) {
return cqImpl, nil
}

func (c *Cache) AdmittedWorkloadsLocalQueue(localQueue *kueue.LocalQueue) int32 {
Copy link
Contributor

Choose a reason for hiding this comment

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

AdmittedWorkloadsInLocalQueue?

defer c.Unlock()
cq, ok := c.clusterQueues[string(localQueue.Spec.ClusterQueue)]
if !ok {
return 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should also return error here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, the ClusterQueue might be created after the LocalQueue.

During that time, there can't be any admitted workloads. So 0 is the right value.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes, that's the case. Another approach is

queueObj.Status.AdmittedWorkloads, _ = r.cache.AdmittedWorkloadsLocalQueue(&queueObj)

But remaining the same also makes sense to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

if there are no cases of error, I would not add error to the return values

@kerthcet
Copy link
Contributor

kerthcet commented Sep 9, 2022

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 9, 2022
Update apis/kueue/v1alpha2/localqueue_types.go

Co-authored-by: Aldo Culquicondor <1299064+alculquicondor@users.noreply.github.com>

Update pkg/cache/cache.go

Co-authored-by: Aldo Culquicondor <1299064+alculquicondor@users.noreply.github.com>

Update pkg/cache/cache_test.go

Co-authored-by: Aldo Culquicondor <1299064+alculquicondor@users.noreply.github.com>

pr changes

Updating localqueue_controller_test to refect AdmittedWorkload add

Pending comment fix

cache flattened

use flattened map with just ns and name

Change function name and cleanup test code
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
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

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

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 Sep 9, 2022
@k8s-ci-robot k8s-ci-robot merged commit b2e20c7 into kubernetes-sigs:main Sep 9, 2022
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 lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add number of AdmittedWorkloads to LocalQueue status
5 participants