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

migrate scheduling_queue.go to structured logging #98358

Merged
merged 1 commit into from
Feb 19, 2021

Conversation

tanjing2020
Copy link
Contributor

@tanjing2020 tanjing2020 commented Jan 25, 2021

What type of PR is this?
/kind cleanup

What this PR does / why we need it:
Ref:
https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/1602-structured-logging
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/migration-to-structured-logging.md

Which issue(s) this PR fixes:

Verify log output (scheduling_queue.go)

before
scheduling_queue.go:253] Error adding pod ns2/mpp to the scheduling queue: couldn't create key for object &{Pod:&Pod{ObjectMeta:{...CST m=+0.016562001}: <nil>
scheduling_queue.go:257] Error: pod ns2/mpp is already in the unschedulable queue.
scheduling_queue.go:262] Error: pod ns2/mpp is already in the podBackoff queue.
scheduling_queue.go:347] Unable to pop pod ns2/mpp from backoff queue despite backoff completion.
scheduling_queue.go:517] Error adding pod up to the backoff queue: couldn't create key for object &{Pod:&Pod{ObjectMeta:{...CST m=+0.018590301}: <nil>
scheduling_queue.go:524] Error adding pod to the scheduling queue: couldn't create key for object &{Pod:&Pod{ObjectMeta:{...CST m=+0.018590301}: <nil>
scheduling_queue.go:547] Error getting label selectors for pod: afp.
scheduling_queue.go:751] Pod ns2/mpp already exists in the nominated map!
scheduling_queue.go:813] About to try and schedule pod ns2/mpp
scheduling_queue.go:816] Error while retrieving next pod from scheduling queue: object was removed from heap data
after
scheduling_queue.go:253] "Error adding pod to the scheduling queue" err="couldn't create key for object &{Pod:&Pod{ObjectMeta:{...CST m=+0.018528101}: <nil>" pod="ns2/mpp"
scheduling_queue.go:257] "Error: pod is already in the unschedulable queue" pod="ns2/mpp"
scheduling_queue.go:262] "Error: pod is already in the podBackoff queue" pod="ns2/mpp"
scheduling_queue.go:347] "Unable to pop pod from backoff queue despite backoff completion" pod="ns2/mpp"
scheduling_queue.go:517] "Error adding pod to the backoff queue" err="couldn't create key for object &{Pod:&Pod{ObjectMeta:{...CST m=+0.016580101}: <nil>" pod="ns1/up"
scheduling_queue.go:524] "Error adding pod to the scheduling queue" err="couldn't create key for object &{Pod:&Pod{ObjectMeta:{...CST m=+0.016580101}: <nil>" pod="ns1/up"
scheduling_queue.go:547] "Error getting label selectors for pod" err="out is not a valid pod selector operator" pod="ns1/afp"
scheduling_queue.go:751] "Pod already exists in the nominated map" pod="ns2/mpp"
scheduling_queue.go:813] "About to try and schedule pod" pod="ns2/mpp"
scheduling_queue.go:816] "Error while retrieving next pod from scheduling queue" err="object was removed from heap data"

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

@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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 25, 2021
@k8s-ci-robot
Copy link
Contributor

@tanjing2020: This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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 needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Jan 25, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @tanjing2020. Thanks for your PR.

I'm waiting for a kubernetes 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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jan 25, 2021
@k8s-ci-robot k8s-ci-robot requested review from damemi and k82cn January 25, 2021 08:16
@k8s-ci-robot k8s-ci-robot added sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 25, 2021
Copy link
Contributor

@damemi damemi left a comment

Choose a reason for hiding this comment

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

/ok-to-test
/lgtm

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

Just notice this one is kind of duplicated with #98135.

@damemi
Copy link
Contributor

damemi commented Jan 25, 2021

Just notice this one is kind of duplicated with #98135.

Ah true, I didn't notice that.
/hold
@tanjing2020 please check out the other PR, and we may close this one as a duplicate

@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 Jan 25, 2021
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 27, 2021
@tanjing2020
Copy link
Contributor Author

#98135 removed duplicate file, please review again, thanks.
@damemi @gavinfish

@k8s-ci-robot k8s-ci-robot removed the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Feb 10, 2021
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 10, 2021
@@ -299,14 +291,14 @@ func (p *PriorityQueue) AddUnschedulableIfNotPresent(pInfo *framework.QueuedPodI
defer p.lock.Unlock()
pod := pInfo.Pod
if p.unschedulableQ.get(pod) != nil {
return fmt.Errorf("pod: %v is already present in unschedulable queue", nsNameForPod(pod))
return fmt.Errorf("pod %v is already present in unschedulable queue", klog.KObj(pod))
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 fmt.Errorf("pod %v is already present in unschedulable queue", klog.KObj(pod))
return fmt.Errorf("Pod is already present in unschedulable queue", "pod", klog.KObj(pod))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Errorf formats according to a format specifier and returns the string as a value that satisfies error.
https://golang.org/pkg/fmt/#Errorf

I think it's better to keep the original modification.

}

if _, exists, _ := p.activeQ.Get(pInfo); exists {
return fmt.Errorf("pod: %v is already present in the active queue", nsNameForPod(pod))
return fmt.Errorf("pod %v is already present in the active queue", klog.KObj(pod))
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 fmt.Errorf("pod %v is already present in the active queue", klog.KObj(pod))
return fmt.Errorf("Pod is already present in the active queue", "pod", klog.KObj(pod))

}
if _, exists, _ := p.podBackoffQ.Get(pInfo); exists {
return fmt.Errorf("pod %v is already present in the backoff queue", nsNameForPod(pod))
return fmt.Errorf("pod %v is already present in the backoff queue", klog.KObj(pod))
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 fmt.Errorf("pod %v is already present in the backoff queue", klog.KObj(pod))
return fmt.Errorf("Pod is already present in the backoff queue", "pod", klog.KObj(pod))

p.unschedulableQ.delete(pod)
}
// Delete pod from backoffQ if it is backing off
if err := p.podBackoffQ.Delete(pInfo); err == nil {
klog.Errorf("Error: pod %v is already in the podBackoff queue.", nsNameForPod(pod))
klog.ErrorS(err, "Error: pod is already in the podBackoff queue", "pod", klog.KObj(pod))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: err is always nil here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

@damemi damemi 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 Feb 18, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: damemi, tanjing2020

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 Feb 18, 2021
@lala123912
Copy link
Contributor

/unhold

@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 Feb 19, 2021
@k8s-ci-robot k8s-ci-robot merged commit 320aaf4 into kubernetes:master Feb 19, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.21 milestone Feb 19, 2021
@tanjing2020 tanjing2020 deleted the scheduling_queue.go branch March 9, 2021 03:52
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Mar 29, 2021
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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. 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. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. 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.

5 participants