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

Fix the issue where Shutdown doesn't shutdown taskqueue #365

Merged
merged 1 commit into from
Oct 30, 2018

Conversation

anfernee
Copy link
Member

Originally, PeriodicTaskQueue has 2 loops:

  • wait.Until managed by stopCh
  • for loop in worker() managed by workqueue

Shutdown only exits the second loop. Failing to close stopCh before
calling Shutdown will cause panic because of double close workDone
channel.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 25, 2018
@rramkumar1
Copy link
Contributor

/assign @bowei

@bowei
Copy link
Member

bowei commented Jun 27, 2018

Is it possible to add a test for the misbehavior?

tq.Enqueue(cache.ExplicitKey("a"))
tq.Enqueue(cache.ExplicitKey("b"))
tq.Enqueue(cache.ExplicitKey("err"))
tq.Enqueue(cache.ExplicitKey("stop"))

<-doneCh
close(stopCh)
Copy link
Member Author

@anfernee anfernee Jun 29, 2018

Choose a reason for hiding this comment

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

@bowei, the main change is to remove the stopCh from tq. Originally in order to shutdown the tq, we need to close the channel and then call tq.Shutdown(). There is no misbehavior with current implementation, only complexity. e.g. close must happen before shutdown, or it's possible that it won't be shutdown.

In terms of test, I think I can add another shutdown, to make sure no panic.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added L56 to test shutdown actually works.

@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 Sep 27, 2018
@bowei
Copy link
Member

bowei commented Oct 14, 2018

can you rebase this?

Originally, PeriodicTaskQueue has 2 loops:
- wait.Until managed by stopCh
- for loop in worker() managed by workqueue

Shutdown only exits the second loop. Failing to close stopCh before
calling Shutdown will cause panic because of double close workDone
channel.
@rramkumar1
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 30, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: anfernee, rramkumar1

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 Oct 30, 2018
@rramkumar1
Copy link
Contributor

/retest

@k8s-ci-robot k8s-ci-robot merged commit fdfb8b8 into kubernetes:master Oct 30, 2018
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. 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