Skip to content

Commit

Permalink
correctly propagate orchestration results of a failed orchestration t…
Browse files Browse the repository at this point in the history
…o the backend. (#2748)
  • Loading branch information
sebastianburckhardt authored Mar 18, 2024
1 parent 0383eed commit 7472dad
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ internal OrchestratorExecutionResult GetResult()
return this.executionResult ?? throw new InvalidOperationException($"The execution result has not yet been set using {nameof(this.SetResult)}.");
}

internal bool TryGetOrchestrationErrorDetails(out string details)
{
if (this.failure != null)
{
details = this.failure.Message;
return true;
}
else
{
details = string.Empty;
return false;
}
}

internal void SetResult(IEnumerable<OrchestratorAction> actions, string customStatus)
{
var result = new OrchestratorExecutionResult
Expand Down
23 changes: 23 additions & 0 deletions src/WebJobs.Extensions.DurableTask/OutOfProcMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,31 @@ await this.LifeCycleNotificationHelper.OrchestratorCompletedAsync(
isReplay: false);
}
}
else if (context.TryGetOrchestrationErrorDetails(out string details))
{
// the function failed because the orchestrator failed.

orchestratorResult = context.GetResult();

this.TraceHelper.FunctionFailed(
this.Options.HubName,
functionName.Name,
instance.InstanceId,
details,
FunctionType.Orchestrator,
isReplay: false);

await this.LifeCycleNotificationHelper.OrchestratorFailedAsync(
this.Options.HubName,
functionName.Name,
instance.InstanceId,
details,
isReplay: false);
}
else
{
// the function failed for some other reason

string exceptionDetails = functionResult.Exception.ToString();

this.TraceHelper.FunctionFailed(
Expand Down

0 comments on commit 7472dad

Please sign in to comment.