-
Notifications
You must be signed in to change notification settings - Fork 1.2k
🐛 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
🐛 Wait for NonLeaderElectionRunnables to terminate #1005
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: michaelgugino 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 |
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. |
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.
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) |
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.
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
}()
pkg/manager/internal.go
Outdated
@@ -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) |
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.
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?
77f4039
to
02a5409
Compare
numRunners := len(cm.nonLeaderElectionRunnables) | ||
for doneCount < numRunners { | ||
select { | ||
case <-returnCh: | ||
doneCount++ | ||
default: | ||
} | ||
} |
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.
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.
02a5409
to
874b022
Compare
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.
/lgtm
Not sure why we would implement this just for non-leader election runnables? |
@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. |
#967 merged. Closing. |
This commit ensures the main Start does not return
prior to NonLeaderElectionRunnables finishing.