mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 03:41:01 +00:00
Wait to finish reading logs before calling Wait() on pipeline (#1010)
This fixes errors like the following and chopped off logs ...
This commit is contained in:
parent
5557674835
commit
7031904dbe
1 changed files with 7 additions and 0 deletions
|
@ -3,6 +3,7 @@ package pipeline
|
|||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
|
@ -216,13 +217,16 @@ func (r *Runtime) exec(step *backend.Step) (*backend.State, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
if r.logger != nil {
|
||||
rc, err := r.engine.Tail(r.ctx, step)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
logger := r.MakeLogger()
|
||||
|
||||
if err := r.logger.Log(step, multipart.New(rc)); err != nil {
|
||||
|
@ -237,6 +241,9 @@ func (r *Runtime) exec(step *backend.Step) (*backend.State, error) {
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
// Some pipeline backends, such as local, will close the pipe from Tail on Wait,
|
||||
// so first make sure all reading has finished.
|
||||
wg.Wait()
|
||||
waitState, err := r.engine.Wait(r.ctx, step)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in a new issue