Skip to content

Commit 2fd45cc

Browse files
authored
[runner] Write termination_{reason,message} to the log (#3550)
1 parent 3ec1a6d commit 2fd45cc

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

runner/internal/executor/base.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ type Executor interface {
1818
SetJobStateWithTerminationReason(
1919
ctx context.Context,
2020
state types.JobState,
21-
termination_reason types.TerminationReason,
22-
termination_message string,
21+
terminationReason types.TerminationReason,
22+
terminationMessage string,
2323
)
2424
SetRunnerState(state string)
2525
WriteFileArchive(id string, src io.Reader) error

runner/internal/executor/executor.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,19 +296,22 @@ func (ex *RunExecutor) SetJobState(ctx context.Context, state types.JobState) {
296296
}
297297

298298
func (ex *RunExecutor) SetJobStateWithTerminationReason(
299-
ctx context.Context, state types.JobState, termination_reason types.TerminationReason, termination_message string,
299+
ctx context.Context, state types.JobState, terminationReason types.TerminationReason, terminationMessage string,
300300
) {
301301
ex.mu.Lock()
302302
ex.jobStateHistory = append(
303303
ex.jobStateHistory,
304304
schemas.JobStateEvent{
305305
State: state,
306306
Timestamp: ex.timestamp.Next(),
307-
TerminationReason: termination_reason,
308-
TerminationMessage: termination_message,
307+
TerminationReason: terminationReason,
308+
TerminationMessage: terminationMessage,
309309
},
310310
)
311311
ex.mu.Unlock()
312+
if terminationReason != "" {
313+
ctx = log.AppendArgsCtx(ctx, "termination_reason", terminationReason, "termination_message", terminationMessage)
314+
}
312315
log.Info(ctx, "Job state changed", "new", state)
313316
}
314317

0 commit comments

Comments
 (0)