Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Wait until ready; make test 810 more reliable #2946

Merged
merged 3 commits into from
May 11, 2017
Merged

Conversation

bboreham
Copy link
Contributor

Various parts of the system initialize asynchronously at startup.
Callers should not attempt operations until all parts are ready; the weave script already delays until curl /status returns 200, but this could happen too early.
So, we introduce a ready function to be called by each sub-part: plugin, proxy, expose; this function comes from a wrapped WaitGroup.
We don't actually wait on the WaitGroup; that could perhaps be simplified, but I thought it was a good idea to follow the pattern.

@bboreham bboreham added this to the 2.0 milestone May 11, 2017
@marccarre marccarre self-requested a review May 11, 2017 14:10
// It would be better if we could delay calling Done() until all
// the listeners are ready, but it doesn't seem to be possible to
// hook the right point in http.Server
ready()
for range listeners {
err := <-errs
if err != nil {

This comment was marked as abuse.

This comment was marked as abuse.

errs := make(chan error)
for _, listener := range listeners {
go func(listener net.Listener) {
errs <- (&http.Server{Handler: proxy}).Serve(listener)
}(listener)
}
// It would be better if we could delay calling Done() until all
// the listeners are ready, but it doesn't seem to be possible to
// hook the right point in http.Server

This comment was marked as abuse.

This comment was marked as abuse.

Copy link
Contributor

@marccarre marccarre left a comment

Choose a reason for hiding this comment

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

LGTM.

@marccarre marccarre merged commit 70929ce into master May 11, 2017
@marccarre marccarre deleted the ready-aim-fire branch May 11, 2017 18:14
@@ -54,6 +54,13 @@ func run(dockerClient *docker.Client, weave *weaveapi.Client, address, meshAddre
defer os.Remove(meshAddress)
defer meshListener.Close()
}
if !isPluginV2 {

This comment was marked as abuse.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants