Commit c2774346 authored by Shinya Maeda's avatar Shinya Maeda

Add failure reason for execution timeout

parent 7092cd26
......@@ -268,7 +268,7 @@ func (b *Build) handleError(err error) error {
case context.DeadlineExceeded:
b.CurrentState = BuildRunRuntimeTimedout
return &BuildError{Inner: fmt.Errorf("execution took longer than %v seconds", b.GetBuildTimeout())}
return &BuildError{Inner: fmt.Errorf("execution took longer than %v seconds", b.GetBuildTimeout()), FailureReason: RunnerExecutionTimeout}
default:
b.CurrentState = BuildRunRuntimeFinished
......@@ -405,9 +405,14 @@ func (b *Build) Run(globalConfig *Config, trace JobTrace) (err error) {
"duration": b.Duration(),
})
if _, ok := err.(*BuildError); ok {
if buildError, ok := err.(*BuildError); ok {
logger.SoftErrorln("Job failed:", err)
trace.Fail(err, ScriptFailure)
if buildError.FailureReason == RunnerExecutionTimeout {
trace.Fail(err, RunnerExecutionTimeout)
} else {
trace.Fail(err, ScriptFailure)
}
} else if err != nil {
logger.Errorln("Job failed (system failure):", err)
trace.Fail(err, RunnerSystemFailure)
......
......@@ -55,6 +55,7 @@ type ExecutorProvider interface {
type BuildError struct {
Inner error
FailureReason JobFailureReason
}
func (b *BuildError) Error() string {
......
......@@ -25,6 +25,7 @@ const (
NoneFailure JobFailureReason = ""
ScriptFailure JobFailureReason = "script_failure"
RunnerSystemFailure JobFailureReason = "runner_system_failure"
RunnerExecutionTimeout JobFailureReason = "runner_execution_timeout"
)
const (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment