From 0e33d8aa876faa9415b54e682fa599e4a611d175 Mon Sep 17 00:00:00 2001 From: sebastianburckhardt Date: Tue, 20 Feb 2024 11:10:06 -0800 Subject: [PATCH] correctly propagate orchestration results of a failed orchestration to the backend. --- .../RemoteOrchestratorContext.cs | 14 +++++++++++ .../OutOfProcMiddleware.cs | 23 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/WebJobs.Extensions.DurableTask/ContextImplementations/RemoteOrchestratorContext.cs b/src/WebJobs.Extensions.DurableTask/ContextImplementations/RemoteOrchestratorContext.cs index 8cc630bf8..5a8a50482 100644 --- a/src/WebJobs.Extensions.DurableTask/ContextImplementations/RemoteOrchestratorContext.cs +++ b/src/WebJobs.Extensions.DurableTask/ContextImplementations/RemoteOrchestratorContext.cs @@ -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 actions, string customStatus) { var result = new OrchestratorExecutionResult diff --git a/src/WebJobs.Extensions.DurableTask/OutOfProcMiddleware.cs b/src/WebJobs.Extensions.DurableTask/OutOfProcMiddleware.cs index cf45c2521..37d051998 100644 --- a/src/WebJobs.Extensions.DurableTask/OutOfProcMiddleware.cs +++ b/src/WebJobs.Extensions.DurableTask/OutOfProcMiddleware.cs @@ -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(