Merge pull request #903 from TomChv/fix/client-waiting-group

Fix waiting group in client runner
This commit is contained in:
Andrea Luzzardi 2021-08-20 18:54:15 +02:00 committed by GitHub
commit 6a73f1de80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -104,8 +104,14 @@ func (c *Client) Do(ctx context.Context, state *state.State, fn DoFunc) error {
}
func (c *Client) buildfn(ctx context.Context, st *state.State, env *environment.Environment, fn DoFunc, ch chan *bk.SolveStatus) error {
wg := sync.WaitGroup{}
// Close output channel
defer close(ch)
defer func() {
// Wait until all the events are caught
wg.Wait()
close(ch)
}()
lg := log.Ctx(ctx)
@ -143,7 +149,6 @@ func (c *Client) buildfn(ctx context.Context, st *state.State, env *environment.
Interface("attrs", opts.FrontendAttrs).
Msg("spawning buildkit job")
wg := sync.WaitGroup{}
// Catch output from events
catchOutput := func(inCh chan *bk.SolveStatus) {
for e := range inCh {
@ -220,8 +225,6 @@ func (c *Client) buildfn(ctx context.Context, st *state.State, env *environment.
Msg("exporter response")
}
// Wait until all the events are caught
wg.Wait()
return nil
}