( ctx context.Context, taskRecord Task, run Run, failure RunFailure, actor ActorContext, opts failRunRecordOptions, )
| 3402 | } |
| 3403 | |
| 3404 | func (m *Service) failRunRecordWithOptions( |
| 3405 | ctx context.Context, |
| 3406 | taskRecord Task, |
| 3407 | run Run, |
| 3408 | failure RunFailure, |
| 3409 | actor ActorContext, |
| 3410 | opts failRunRecordOptions, |
| 3411 | ) (*Run, error) { |
| 3412 | switch run.Status.Normalize() { |
| 3413 | case TaskRunStatusStarting, TaskRunStatusRunning: |
| 3414 | default: |
| 3415 | return nil, requireRunTransition(run, TaskRunStatusFailed) |
| 3416 | } |
| 3417 | |
| 3418 | run.Status = TaskRunStatusFailed |
| 3419 | run.Error = failure.Error |
| 3420 | run.Result = nil |
| 3421 | run.ClaimToken = "" |
| 3422 | run.LeaseUntil = time.Time{} |
| 3423 | run.HeartbeatAt = time.Time{} |
| 3424 | run.EndedAt = m.now().UTC() |
| 3425 | if opts.stopTerminalSession { |
| 3426 | if err := m.stopTerminalRunSession(ctx, run, StopReasonFailed); err != nil { |
| 3427 | return nil, err |
| 3428 | } |
| 3429 | } |
| 3430 | if err := m.store.UpdateTaskRun(ctx, run); err != nil { |
| 3431 | return nil, err |
| 3432 | } |
| 3433 | |
| 3434 | reconciledTask, err := m.reconcileTaskCascade(ctx, taskRecord.ID) |
| 3435 | if err != nil { |
| 3436 | return nil, err |
| 3437 | } |
| 3438 | if err := m.recordTaskEvent(ctx, run.TaskID, run.ID, taskEventRunFailed, actor, failedRunPayload{ |
| 3439 | Status: run.Status, |
| 3440 | TaskStatus: reconciledTask.Status, |
| 3441 | Error: run.Error, |
| 3442 | Metadata: cloneRawJSON(failure.Metadata), |
| 3443 | }); err != nil { |
| 3444 | return nil, err |
| 3445 | } |
| 3446 | m.dispatchTerminalWake(ctx, reconciledTask, run, actor) |
| 3447 | |
| 3448 | return &run, nil |
| 3449 | } |
| 3450 | |
| 3451 | func (m *Service) cancelRunRecord( |
| 3452 | ctx context.Context, |
no test coverage detected