mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-10-21 08:27:02 +00:00
Added support for step errors when executing backend (#817)
When executing a backend step, in case of failure of the specific step, the run is marked as errored but the step error is missing. Added: 1. Log for the backend error (without trace) 2. Mark the step as errored with exit code 126 (Could not execute). Co-authored-by: Zav Shotan <zshotan@bloomberg.net> Co-authored-by: Anton Bracke <anton@ju60.de>
This commit is contained in:
@@ -31,6 +31,7 @@ import (
|
||||
backend "github.com/woodpecker-ci/woodpecker/pipeline/backend/types"
|
||||
"github.com/woodpecker-ci/woodpecker/pipeline/multipart"
|
||||
"github.com/woodpecker-ci/woodpecker/pipeline/rpc"
|
||||
"github.com/woodpecker-ci/woodpecker/shared/utils"
|
||||
)
|
||||
|
||||
// TODO: Implement log streaming.
|
||||
@@ -98,6 +99,13 @@ func (r *Runner) Run(ctx context.Context) error {
|
||||
ctx, cancel := context.WithTimeout(ctxmeta, timeout)
|
||||
defer cancel()
|
||||
|
||||
// Add sigterm support for internal context.
|
||||
// Required when the pipeline is terminated by external signals
|
||||
// like kubernetes.
|
||||
ctx = utils.WithContextSigtermCallback(ctx, func() {
|
||||
logger.Error().Msg("Received sigterm termination signal")
|
||||
})
|
||||
|
||||
canceled := abool.New()
|
||||
go func() {
|
||||
logger.Debug().Msg("listen for cancel signal")
|
||||
@@ -241,6 +249,7 @@ func (r *Runner) Run(ctx context.Context) error {
|
||||
proclogger := logger.With().
|
||||
Str("image", state.Pipeline.Step.Image).
|
||||
Str("stage", state.Pipeline.Step.Alias).
|
||||
Err(state.Process.Error).
|
||||
Int("exit_code", state.Process.ExitCode).
|
||||
Bool("exited", state.Process.Exited).
|
||||
Logger()
|
||||
@@ -252,6 +261,10 @@ func (r *Runner) Run(ctx context.Context) error {
|
||||
Started: time.Now().Unix(), // TODO do not do this
|
||||
Finished: time.Now().Unix(),
|
||||
}
|
||||
if state.Process.Error != nil {
|
||||
procState.Error = state.Process.Error.Error()
|
||||
}
|
||||
|
||||
defer func() {
|
||||
proclogger.Debug().Msg("update step status")
|
||||
|
||||
|
Reference in New Issue
Block a user