Skip to content

Commit

Permalink
Mark job as failed on worker crash. (#3006)
Browse files Browse the repository at this point in the history
  • Loading branch information
TingluoHuang committed Nov 27, 2023
1 parent 8a25302 commit 661b261
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Runner.Listener/JobDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,15 @@ private async Task LogWorkerProcessUnhandledException(IRunnerService server, Pip
jobRecord.ErrorCount++;
jobRecord.Issues.Add(unhandledExceptionIssue);

if (message.Variables.TryGetValue("DistributedTask.MarkJobAsFailedOnWorkerCrash", out var markJobAsFailedOnWorkerCrash) &&
StringUtil.ConvertToBoolean(markJobAsFailedOnWorkerCrash?.Value))
{
Trace.Info("Mark the job as failed since the worker crashed");
jobRecord.Result = TaskResult.Failed;
// mark the job as completed so service will pickup the result
jobRecord.State = TimelineRecordState.Completed;
}

await jobServer.UpdateTimelineRecordsAsync(message.Plan.ScopeIdentifier, message.Plan.PlanType, message.Plan.PlanId, message.Timeline.Id, new TimelineRecord[] { jobRecord }, CancellationToken.None);
}
catch (Exception ex)
Expand Down

0 comments on commit 661b261

Please sign in to comment.