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

improve procfs.PidOf return error #89718

Closed
wants to merge 3 commits into from
Closed

improve procfs.PidOf return error #89718

wants to merge 3 commits into from

Conversation

xigang
Copy link
Contributor

@xigang xigang commented Apr 1, 2020

improve procfs.PidOf return error

What type of PR is this?
/kind cleanup

What this PR does / why we need it:
none
Which issue(s) this PR fixes:
Fixes #

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.:

none

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Apr 1, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @xigang. 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 the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 1, 2020
@xigang
Copy link
Contributor Author

xigang commented Apr 1, 2020

/ok-to-test

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: xigang
To complete the pull request process, please assign yujuhong
You can assign the PR to them by writing /assign @yujuhong in a comment when ready.

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

@xigang: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/ok-to-test

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 area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 1, 2020
@xigang
Copy link
Contributor Author

xigang commented Apr 1, 2020

/assign @yujuhon

@k8s-ci-robot
Copy link
Contributor

@xigang: GitHub didn't allow me to assign the following users: yujuhon.

Note that only kubernetes members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @yujuhon

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.

@yuzhiquan
Copy link
Member

/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 Apr 1, 2020
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 1, 2020
@yuzhiquan
Copy link
Member

/assign @yujuhong

@xigang
Copy link
Contributor Author

xigang commented Apr 1, 2020

/test pull-kubernetes-node-e2e-containerd
/test pull-kubernetes-e2e-kind

@xigang
Copy link
Contributor Author

xigang commented Apr 1, 2020

/test pull-kubernetes-e2e-kind

Copy link
Contributor

@mattjmcnaughton mattjmcnaughton left a comment

Choose a reason for hiding this comment

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

/lgtm

pids, err2 := procfs.PidOf(name)
if err2 == nil {
pids, pidsErr := procfs.PidOf(name)
if pidsErr == nil {
Copy link
Member

Choose a reason for hiding this comment

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

seems like we could change this block and the one above to be like the following:

if pids, err := foo(name); err == nil {
 return pids
}

otherwise err and err2 in this same function are equally descriptive...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@derekwaynecarr the modification is completed, please review again.

@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot added do-not-merge/contains-merge-commits Indicates a PR which contains merge commits. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Apr 7, 2020
@k8s-ci-robot
Copy link
Contributor

@xigang: Adding label do-not-merge/contains-merge-commits because PR contains merge commits, which are not allowed in this repository.
Use git rebase to reapply your commits on top of the target branch. Detailed instructions for doing so can be found 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.

@xigang xigang changed the title improve procfs.PidOf return value error improve procfs.PidOf return error Apr 7, 2020
@xigang
Copy link
Contributor Author

xigang commented Apr 7, 2020

/test pull-kubernetes-conformance-kind-ga-only-parallel

@xigang
Copy link
Contributor Author

xigang commented Apr 7, 2020

/retest

@xigang
Copy link
Contributor Author

xigang commented Apr 7, 2020

/test pull-kubernetes-node-e2e-containerd

3 similar comments
@xigang
Copy link
Contributor Author

xigang commented Apr 7, 2020

/test pull-kubernetes-node-e2e-containerd

@xigang
Copy link
Contributor Author

xigang commented Apr 7, 2020

/test pull-kubernetes-node-e2e-containerd

@xigang
Copy link
Contributor Author

xigang commented Apr 7, 2020

/test pull-kubernetes-node-e2e-containerd

@xigang
Copy link
Contributor Author

xigang commented Apr 7, 2020

/retest

@k8s-ci-robot
Copy link
Contributor

@xigang: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-kubernetes-node-e2e-containerd e81f983 link /test pull-kubernetes-node-e2e-containerd

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

@xigang
Copy link
Contributor Author

xigang commented Apr 7, 2020

@derekwaynecarr the pull-kubernetes-node-e2e-containerd test case fails:(

pids, err2 := procfs.PidOf(name)
if err2 == nil {
pids, err := procfs.PidOf(name)
if err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

This stuff is tricky :) Re the comment on line 813, don't we want to log/return the error from getPidFromFile? When we assign err here, we overwrite that value.

I think, if err is defined inline, than its online available in the scope of the if statement - see https://www.calhoun.io/one-liner-if-statements-with-errors/, particularly "This is also why we can have an existing variable named err and then redeclare it inside of an if statement. The new variable is in a new scope, so it is permitted by the compiler.".

So I think we want to use the exact code @derekwaynecarr linked :)

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 6, 2020
@derekwaynecarr
Copy link
Member

Thank you for the proposed change.

It appears the change is not using the idiomatic style suggested here:
#89718 (comment)

I am closing this PR given it is stale, but feel free to re-open and make the requested change at a later time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/contains-merge-commits Indicates a PR which contains merge commits. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. needs-priority Indicates a PR lacks a `priority/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/node Categorizes an issue or PR as relevant to SIG Node. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants