🐛 Wait for NonLeaderElectionRunnables to terminate#1005
🐛 Wait for NonLeaderElectionRunnables to terminate#1005michaelgugino wants to merge 1 commit intokubernetes-sigs:masterfrom
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. DetailsNeeds 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. |
JoelSpeed
left a comment
There was a problem hiding this comment.
Approach looks good, left a couple of suggestions for improvements
|
|
||
| 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.
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
| } | ||
|
|
||
| go cm.startNonLeaderElectionRunnables() | ||
| doneCh := make(chan error, 1) |
There was a problem hiding this comment.
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.
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
|
Not sure why we would implement this just for non-leader election runnables? |
|
@michaelgugino: PR needs rebase. DetailsInstructions 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.