Skip to content

🐛 Wait for NonLeaderElectionRunnables to terminate #1005

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

Conversation

michaelgugino
Copy link

This commit ensures the main Start does not return
prior to NonLeaderElectionRunnables finishing.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 18, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: michaelgugino
To complete the pull request process, please assign joelanford
You can assign the PR to them by writing /assign @joelanford 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 the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 18, 2020
@michaelgugino
Copy link
Author

This is a simple alternative to #967

Currently, running envTest with webhooks results in all sorts of craziness due to the next test starting before the webhooks actually finish.

If the other solutions are not near merging, this one might be useful to some in the intermediate.

Copy link
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

Approach looks good, left a couple of suggestions for improvements

@@ -437,7 +437,6 @@ func (cm *controllerManager) serveHealthProbes(stop <-chan struct{}) {

func (cm *controllerManager) Start(stop <-chan struct{}) error {
// join the passed-in stop channel as an upstream feeding into cm.internalStopper
defer close(cm.internalStopper)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this work as an alternative? This should wait for the done channel on all exits from this function without having to explicitly write it at all exits from the function

doneCh := make(chan error, 1)
defer func() {
  close(cm.internalStopper)
  <-doneCh
}()

@@ -454,11 +453,14 @@ func (cm *controllerManager) Start(stop <-chan struct{}) error {
go cm.serveHealthProbes(cm.internalStop)
}

go cm.startNonLeaderElectionRunnables()
doneCh := make(chan error, 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we never put any errors on this, the convention within this code seems to be to use a chan struct{} as a signal channel, can we modify the PR to use that instead?

@michaelgugino michaelgugino force-pushed the wait-for-webhooks branch 3 times, most recently from 77f4039 to 02a5409 Compare June 19, 2020 14:20
Comment on lines +512 to +518
numRunners := len(cm.nonLeaderElectionRunnables)
for doneCount < numRunners {
select {
case <-returnCh:
doneCount++
default:
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This works and I'm fine with it, though it does make me think of a sync.WaitGroup, are we effectively reimplementing that?

This commit ensures the main Start does not return
prior to NonLeaderElectionRunnables finishing.
Copy link
Contributor

@JoelSpeed JoelSpeed 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 Jun 25, 2020
@alvaroaleman
Copy link
Member

Not sure why we would implement this just for non-leader election runnables?
/hold

@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 Jun 26, 2020
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 21, 2020
@k8s-ci-robot
Copy link
Contributor

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

@michaelgugino
Copy link
Author

#967 merged. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants