-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Fix a potential goroutine leak #114071
Fix a potential goroutine leak #114071
Conversation
Please note that we're already in Test Freeze for the Fast forwards are scheduled to happen every 6 hours, whereas the most recent run was: Tue Nov 22 09:29:40 UTC 2022. |
Welcome @Mskxn! |
Hi @Mskxn. 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 Once the patch is verified, the new status will be reflected by the 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. |
Unknown CLA label state. Rechecking for CLA labels. Send feedback to sig-contributor-experience at kubernetes/community. /check-cla |
can you add a test demonstrating the problem? |
/assign @aojea |
/ok-to-test Thanks |
/lgtm |
@@ -105,7 +105,7 @@ func (r *EtcdMigrateServer) Stop() error { | |||
} | |||
gracefulWait := time.Minute * 2 | |||
stopped := make(chan bool) | |||
timedout := make(chan bool) | |||
timedout := make(chan bool, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of that, instead of sending an item to a channel, we should simply close it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
/hold |
@@ -108,7 +108,7 @@ func (r *EtcdMigrateServer) Stop() error { | |||
timedout := make(chan bool) | |||
go func() { | |||
time.Sleep(gracefulWait) | |||
timedout <- true | |||
close(timedout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given you're touching it, can you please also fix line 72:
https://github.com/kubernetes/kubernetes/blob/96360055842db86ff883993824a9b9bd0563b58e/cluster/images/etcd/migrate/migrate_server.go#L72
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@Mskxn - please squash commits, one squashed, this LGTM |
Close the channel instead of write to it to avoid hanging goroutine.
squashed and PTAL. |
/lgtm /hold cancel /milestone v1.27 |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aojea, Mskxn, wojtek-t 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 |
/retest |
What type of PR is this?
/kind bug
What this PR does / why we need it:
When the server stopped before timeout, the
stopped <-true
will be executed and in the select block, the first case will be chosen. This will lead to a hanging goroutine at line 111 because no receiver oftimeout
is left. Changing thetimeout
chan to a buffered one can fix it.Which issue(s) this PR fixes:
Fixes #114070
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: