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

node pods e2e test: fix goroutine leak #91607

Closed

Conversation

gaurav1086
Copy link
Contributor

@gaurav1086 gaurav1086 commented May 31, 2020

Signed-off-by: Gaurav Singh gaurav1086@gmail.com

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespace from that line:

/kind api-change
/kind bug
/kind cleanup
/kind deprecation
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:
the channel ch need to be buffered to prevent the goroutine in from hanging indefinitely
when the select statement reads something other than the one the goroutine sends on. i.e. timeouts
xref: #5316
The fix is to evaluate over all the events in the ch in case of timeout.
Which issue(s) this PR fixes:

Fixes #
N/A
Special notes for your reviewer:
xref: #5316
https://play.golang.com/p/7zEa7TDXECh
Does this PR introduce a user-facing change?:

NONE

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

NONE

Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. 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 May 31, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @gaurav1086. 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 May 31, 2020
@k8s-ci-robot k8s-ci-robot requested review from sjenning and yujuhong May 31, 2020 01:54
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: gaurav1086
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 k8s-ci-robot added area/test sig/node Categorizes an issue or PR as relevant to SIG Node. sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 31, 2020
@gaurav1086
Copy link
Contributor Author

/assign @yujuhong

@tanjunchen
Copy link
Member

/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 Jun 7, 2020
Copy link
Member

@tanjunchen tanjunchen left a comment

Choose a reason for hiding this comment

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

/cc @oomichi

@k8s-ci-robot k8s-ci-robot requested a review from oomichi June 7, 2020 14:39
test/e2e/node/pods.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 7, 2020
@gaurav1086
Copy link
Contributor Author

/retest

@oomichi
Copy link
Member

oomichi commented Jun 9, 2020

I don't get the point of this PR.
Are you facing actual issue like failing this test related to this change?

Even if not specifying the size of buffer, select works for both receiving and timeout as the following sample:

$ cat main.go 

package main

import "time"

func main() {
        var ch = make(chan int)

        go func() {
                time.Sleep(10 * time.Second)
                ch <- 10
        }()

        select {
        case val, ok := <-ch:
                if !ok {
                        print("ok is not true")
                }
                print("only got a single event: ", val)
        case <-time.After(5 * time.Second):
                print("timeout")
        }
}
$
$ go run main.go 
timeout

It is nice to submit the corresponding issue on github to share what you are trying to solve.

@gaurav1086
Copy link
Contributor Author

I don't get the point of this PR.
Are you facing actual issue like failing this test related to this change?

Even if not specifying the size of buffer, select works for both receiving and timeout as the following sample:

$ cat main.go 

package main

import "time"

func main() {
        var ch = make(chan int)

        go func() {
                time.Sleep(10 * time.Second)
                ch <- 10
        }()

        select {
        case val, ok := <-ch:
                if !ok {
                        print("ok is not true")
                }
                print("only got a single event: ", val)
        case <-time.After(5 * time.Second):
                print("timeout")
        }
}
$
$ go run main.go 
timeout

It is nice to submit the corresponding issue on github to share what you are trying to solve.

@oomichi add the sync.WaitGroup{} to expose this issue like this: https://play.golang.com/p/7zEa7TDXECh

@oomichi
Copy link
Member

oomichi commented Jun 10, 2020

@oomichi add the sync.WaitGroup{} to expose this issue like this: https://play.golang.com/p/7zEa7TDXECh

Thanks for the explanation. I got the point.
But in this file, the sync.WaitGroup() doesn't exist.
and wg.Wait() exists in the file but it seems for outside of this goroutine.

Again, could submit the corresponding issue on github to explain what issue you are facing actually?

@gaurav1086
Copy link
Contributor Author

@oomichi add the sync.WaitGroup{} to expose this issue like this: https://play.golang.com/p/7zEa7TDXECh

Thanks for the explanation. I got the point.
But in this file, the sync.WaitGroup() doesn't exist.
and wg.Wait() exists in the file but it seems for outside of this goroutine.

Again, could submit the corresponding issue on github to explain what issue you are facing actually?
@oomichi Here's a related issue: xref: #5316

@oomichi
Copy link
Member

oomichi commented Jun 10, 2020

@gaurav1086
The issue doesn't happen on current e2e test, right?

@gaurav1086 gaurav1086 requested a review from tanjunchen June 10, 2020 23:18
@gaurav1086
Copy link
Contributor Author

@gaurav1086
The issue doesn't happen on current e2e test, right?

@oomichi Not that I'm aware of since leaks are usually hard to catch.

@gaurav1086
Copy link
Contributor Author

cc @lavalamp @sttts

test/e2e/node/pods.go Outdated Show resolved Hide resolved
Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 11, 2020
@gaurav1086 gaurav1086 requested a review from lavalamp July 11, 2020 18:57
@gaurav1086 gaurav1086 changed the title node pods e2e test: fix leak node pods e2e test: fix goroutine leak Jul 11, 2020
@k8s-ci-robot
Copy link
Contributor

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

Test name Commit Details Rerun command
pull-kubernetes-e2e-gce-ubuntu-containerd ccf8ad7 link /test pull-kubernetes-e2e-gce-ubuntu-containerd
pull-kubernetes-conformance-kind-ga-only-parallel ccf8ad7 link /test pull-kubernetes-conformance-kind-ga-only-parallel
pull-kubernetes-e2e-gce-device-plugin-gpu ccf8ad7 link /test pull-kubernetes-e2e-gce-device-plugin-gpu
pull-kubernetes-e2e-gce-100-performance ccf8ad7 link /test pull-kubernetes-e2e-gce-100-performance
pull-kubernetes-kubemark-e2e-gce-big ccf8ad7 link /test pull-kubernetes-kubemark-e2e-gce-big
pull-kubernetes-bazel-build ccf8ad7 link /test pull-kubernetes-bazel-build
pull-kubernetes-bazel-test ccf8ad7 link /test pull-kubernetes-bazel-test
pull-kubernetes-typecheck ccf8ad7 link /test pull-kubernetes-typecheck
pull-kubernetes-e2e-gce ccf8ad7 link /test pull-kubernetes-e2e-gce
pull-kubernetes-node-e2e ccf8ad7 link /test pull-kubernetes-node-e2e
pull-kubernetes-conformance-kind-ipv6-parallel ccf8ad7 link /test pull-kubernetes-conformance-kind-ipv6-parallel
pull-kubernetes-e2e-kind ccf8ad7 link /test pull-kubernetes-e2e-kind
pull-kubernetes-verify ccf8ad7 link /test pull-kubernetes-verify

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.

// Iterate over the events and stop them to avoid leak
for i := 0; i < numEvents; i++ {
w := <-ch
w.Stop()
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this should compile.

@@ -319,6 +321,11 @@ var _ = SIGDescribe("Pods Extended", func() {
}
case <-time.After(5 * time.Minute):
framework.Failf("timed out waiting for watch events for %s", pod.Name)
// Iterate over the events and stop them to avoid leak
for i := 0; i < numEvents; i++ {
Copy link
Member

Choose a reason for hiding this comment

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

numEvents isn't synchronized, this should be a data race.

I think you need to temporarily artificially break the test to ensure that it goes through this timeout case, to test your fix to this timeout case.

@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 Oct 11, 2020
@k8s-ci-robot
Copy link
Contributor

@gaurav1086: PR needs rebase.

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-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 11, 2020
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

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 rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Nov 10, 2020
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

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

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closed this PR.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants