mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-10-21 08:27:02 +00:00
Refactor agent (#2021)
- code cleanup - init backend engine only once - pass a taskUUID to the backend --- *Sponsored by Kithara Software GmbH*
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
@@ -28,7 +27,7 @@ import (
|
||||
"github.com/woodpecker-ci/woodpecker/pipeline/rpc"
|
||||
)
|
||||
|
||||
func (r *Runner) createLogger(_ context.Context, logger zerolog.Logger, uploads *sync.WaitGroup, work *rpc.Pipeline) pipeline.LogFunc {
|
||||
func (r *Runner) createLogger(logger zerolog.Logger, uploads *sync.WaitGroup, work *rpc.Pipeline) pipeline.LogFunc {
|
||||
return func(step *backend.Step, rc multipart.Reader) error {
|
||||
loglogger := logger.With().
|
||||
Str("image", step.Image).
|
||||
@@ -55,12 +54,8 @@ func (r *Runner) createLogger(_ context.Context, logger zerolog.Logger, uploads
|
||||
log.Error().Err(err).Msg("copy limited logStream part")
|
||||
}
|
||||
|
||||
loglogger.Debug().Msg("log stream copied")
|
||||
|
||||
defer func() {
|
||||
loglogger.Debug().Msg("log stream closed")
|
||||
uploads.Done()
|
||||
}()
|
||||
loglogger.Debug().Msg("log stream copied, close ...")
|
||||
uploads.Done()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@ package agent
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -140,7 +141,8 @@ func (r *Runner) Run(runnerCtx context.Context) error {
|
||||
var uploads sync.WaitGroup
|
||||
err = pipeline.New(work.Config,
|
||||
pipeline.WithContext(workflowCtx),
|
||||
pipeline.WithLogger(r.createLogger(ctxmeta, logger, &uploads, work)),
|
||||
pipeline.WithTaskUUID(fmt.Sprint(work.ID)),
|
||||
pipeline.WithLogger(r.createLogger(logger, &uploads, work)),
|
||||
pipeline.WithTracer(r.createTracer(ctxmeta, logger, work)),
|
||||
pipeline.WithEngine(*r.engine),
|
||||
pipeline.WithDescription(map[string]string{
|
||||
|
Reference in New Issue
Block a user