Skip to content

Commit dd46ef6

Browse files
authored
Properly report when command reached timeout (#101)
Before this we just reported that the process was killed, but not that the kill signal was triggered by the timeout.
1 parent 7fa1a89 commit dd46ef6

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

cmd/src/actions_exec_backend_runner.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (x *actionExecutor) do(ctx context.Context, repo ActionRepo) (err error) {
8686
}
8787
}
8888
if err != nil {
89-
if errors.Cause(err) == context.DeadlineExceeded {
89+
if reachedTimeout(runCtx, err) {
9090
err = &errTimeoutReached{timeout: x.opt.timeout}
9191
}
9292
status.Err = err
@@ -112,6 +112,16 @@ func (e *errTimeoutReached) Error() string {
112112
return fmt.Sprintf("Timeout reached. Execution took longer than %s.", e.timeout)
113113
}
114114

115+
func reachedTimeout(cmdCtx context.Context, err error) bool {
116+
if ee, ok := errors.Cause(err).(*exec.ExitError); ok {
117+
if ee.String() == "signal: killed" && cmdCtx.Err() == context.DeadlineExceeded {
118+
return true
119+
}
120+
}
121+
122+
return errors.Is(err, context.DeadlineExceeded)
123+
}
124+
115125
func runAction(ctx context.Context, prefix, repoID, repoName, rev string, steps []*ActionStep, logFile io.Writer) ([]byte, error) {
116126
fmt.Fprintf(logFile, "# Repository %s @ %s (%d steps)\n", repoName, rev, len(steps))
117127

0 commit comments

Comments
 (0)