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

Added Log output for LocalQueue and ClusterQueue #3605

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

7h3-3mp7y-m4n
Copy link

@7h3-3mp7y-m4n 7h3-3mp7y-m4n commented Nov 20, 2024

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

This PR added Log output for LocalQueue and ClusterQueue

Which issue(s) this PR fixes:

Fixes #3527

Special notes for your reviewer:

It added some log output for better debugging without breaking the function..

Does this PR introduce a user-facing change?

NONE

NONE

@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 20, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 7h3-3mp7y-m4n
Once this PR has been reviewed and has the lgtm label, please assign mimowo for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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
Copy link
Contributor

Welcome @7h3-3mp7y-m4n!

It looks like this is your first PR to kubernetes-sigs/kueue 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kueue has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 20, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @7h3-3mp7y-m4n. 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-sigs/prow repository.

Copy link

netlify bot commented Nov 20, 2024

Deploy Preview for kubernetes-sigs-kueue canceled.

Name Link
🔨 Latest commit 84d415a
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-kueue/deploys/674721ffe9e583000850bb3a

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 20, 2024
@@ -329,12 +330,14 @@ func (m *Manager) AddOrUpdateWorkloadWithoutLock(w *kueue.Workload) bool {
qKey := workload.QueueKey(w)
q := m.localQueues[qKey]
if q == nil {
log.Printf("LocalQueue for workload not found; queueKey: %s, workload: %s", qKey, w.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it’s much better to return an error here with a message like 'LocalQueue for workload not found' or 'ClusterQueue for workload not found'.

Copy link
Author

Choose a reason for hiding this comment

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

for sure :)

@@ -20,6 +20,7 @@ import (
"context"
"errors"
"fmt"
"log"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't use this logger.

Copy link
Author

Choose a reason for hiding this comment

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

Okay, I'll replace it with fmt

Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need logger at all. You need to return error instead.

@k8s-ci-robot
Copy link
Contributor

@mbobrovskyi: /release-note-edit must be used with a release note block.

In response to this:

/release-note-edit

NONE

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-sigs/prow repository.

@mbobrovskyi
Copy link
Contributor

/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 Nov 21, 2024
@mbobrovskyi
Copy link
Contributor

/release-note-edit

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Nov 21, 2024
@mimowo
Copy link
Contributor

mimowo commented Nov 21, 2024

/assign @gabesaba

Signed-off-by: 7h3-3mp7y-m4n <[email protected]>
Signed-off-by: 7h3-3mp7y-m4n <[email protected]>
@@ -329,12 +329,14 @@ func (m *Manager) AddOrUpdateWorkloadWithoutLock(w *kueue.Workload) bool {
qKey := workload.QueueKey(w)
q := m.localQueues[qKey]
if q == nil {
fmt.Println("LocalQueue for workload not found")
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
fmt.Println("LocalQueue for workload not found")
return ErrQueueDoesNotExist

Copy link
Author

Choose a reason for hiding this comment

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

okay!

return false
}
wInfo := workload.NewInfo(w, m.workloadInfoOptions...)
q.AddOrUpdate(wInfo)
cq := m.hm.ClusterQueues[q.ClusterQueue]
if cq == nil {
fmt.Println("ClusterQueue for workload not found")
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
fmt.Println("ClusterQueue for workload not found")
return ErrClusterQueueDoesNotExist

Copy link
Author

Choose a reason for hiding this comment

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

okay!

Copy link
Author

Choose a reason for hiding this comment

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

if we do this then we have to change the type of the function cause it was returning a bool and after adding this it should return error ..
so should I add it like you mentioned or anything other?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, sure.

Copy link
Author

Choose a reason for hiding this comment

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

okay!

@gabesaba
Copy link
Contributor

There are some other log lines related to this issue:

e.g. these two, as AddOrUpdateWorkload calls AddOrUpdateWorkloadWithoutLock

if !r.queues.AddOrUpdateWorkload(wlCopy) {
log.V(2).Info("LocalQueue for workload didn't exist or not active; ignored for now")
}

if !r.queues.AddOrUpdateWorkload(wlCopy) {
log.V(2).Info("LocalQueue for workload didn't exist or not active; ignored for now")
} else {

Could you track those down - there may be more than just the two I linked - and update them as well please?

@7h3-3mp7y-m4n
Copy link
Author

There are some other log lines related to this issue:

e.g. these two, as AddOrUpdateWorkload calls AddOrUpdateWorkloadWithoutLock

if !r.queues.AddOrUpdateWorkload(wlCopy) {
log.V(2).Info("LocalQueue for workload didn't exist or not active; ignored for now")
}

if !r.queues.AddOrUpdateWorkload(wlCopy) {
log.V(2).Info("LocalQueue for workload didn't exist or not active; ignored for now")
} else {

Could you track those down - there may be more than just the two I linked - and update them as well please?

Yeah, I'll do that as well :)

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 26, 2024
@7h3-3mp7y-m4n
Copy link
Author

Hey @mbobrovskyi and @gabesaba,
The PR is still a work in progress, but I wanted to share what I've done so far and check if I'm on the right track.
While working on it, I noticed a similar cache function here: workload_controller.go#L712. Should I update that as well?
Also, for the test case, since I added a new parameter in the code, I think I'll need to update the test here: manager_test.go#L421. and I think I have to add a new parameter, am I right? Thanks!

}
wInfo := workload.NewInfo(w, m.workloadInfoOptions...)
q.AddOrUpdate(wInfo)
cq := m.hm.ClusterQueues[q.ClusterQueue]
if cq == nil {
return false
return errClusterQueueAlreadyExists
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
return errClusterQueueAlreadyExists
return ErrClusterQueueDoesNotExist

log.V(2).Info("LocalQueue for workload didn't exist or not active; ignored for now")
err := r.queues.AddOrUpdateWorkload(wlCopy)
if err != nil {
log.V(2).Info(err.Error())
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
log.V(2).Info(err.Error())
log.V(2).Info(fmt.Sprintf("%s; ignored for now", err))

log.V(2).Info("LocalQueue for workload didn't exist or not active; ignored for now")
err := r.queues.AddOrUpdateWorkloadWithoutLock(wlCopy)
if err != nil {
log.V(2).Info(err.Error())
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
log.V(2).Info(err.Error())
log.V(2).Info(fmt.Sprintf("%s; ignored for now", err))

log.V(2).Info("Queue for updated workload didn't exist; ignoring for now")
err := r.queues.UpdateWorkload(oldWl, wlCopy)
if err != nil {
log.V(2).Info(err.Error())
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
log.V(2).Info(err.Error())
log.V(2).Info(fmt.Sprintf("%s; ignored for now", err))

log.V(2).Info("LocalQueue for workload didn't exist or not active; ignored for now")
err := r.queues.AddOrUpdateWorkload(wlCopy)
if err != nil {
log.V(2).Info(err.Error())
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
log.V(2).Info(err.Error())
log.V(2).Info(fmt.Sprintf("%s; ignored for now", err))

Copy link
Contributor

Choose a reason for hiding this comment

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

To have the same message.

Copy link
Author

Choose a reason for hiding this comment

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

for sure I'll add them :)

@mbobrovskyi
Copy link
Contributor

Hey @mbobrovskyi and @gabesaba, The PR is still a work in progress, but I wanted to share what I've done so far and check if I'm on the right track. While working on it, I noticed a similar cache function here: workload_controller.go#L712. Should I update that as well? Also, for the test case, since I added a new parameter in the code, I think I'll need to update the test here: manager_test.go#L421. and I think I have to add a new parameter, am I right? Thanks!

Yeah, we need to update tests as well.

@7h3-3mp7y-m4n
Copy link
Author

Hey @mbobrovskyi and @gabesaba, The PR is still a work in progress, but I wanted to share what I've done so far and check if I'm on the right track. While working on it, I noticed a similar cache function here: workload_controller.go#L712. Should I update that as well? Also, for the test case, since I added a new parameter in the code, I think I'll need to update the test here: manager_test.go#L421. and I think I have to add a new parameter, am I right? Thanks!

Yeah, we need to update tests as well.

I'll share it with you ASAP, Thanks! @mbobrovskyi

Signed-off-by: 7h3-3mp7y-m4n <[email protected]>
Signed-off-by: 7h3-3mp7y-m4n <[email protected]>
@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Nov 27, 2024

@7h3-3mp7y-m4n: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kueue-verify-main 84d415a link true /test pull-kueue-verify-main

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. 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.

Imprecise log line: LocalQueue for workload didn't exist
5 participants