-
Notifications
You must be signed in to change notification settings - Fork 204
Sending EnableUserCodeException as a capability of native worker #1960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,15 +56,17 @@ private async Task Process(StreamingMessage msg) | |
|
|
||
| if (workerConfig?.Description is null) | ||
| { | ||
| responseMessage.FunctionEnvironmentReloadResponse = BuildFailedEnvironmentReloadResponse(new FunctionAppPayloadNotFoundException()); | ||
| Logger.LogTrace($"Could not find a worker config in {envReloadRequest.FunctionAppDirectory}"); | ||
| responseMessage.FunctionEnvironmentReloadResponse = BuildFailedEnvironmentReloadResponse(); | ||
| break; | ||
| } | ||
|
|
||
| // function app payload which uses an older version of Microsoft.Azure.Functions.Worker package does not support specialization. | ||
| if (!workerConfig.Description.CanUsePlaceholder) | ||
| { | ||
| Logger.LogTrace("App payload uses an older version of worker package which does not support specialization."); | ||
| responseMessage.FunctionEnvironmentReloadResponse = BuildFailedEnvironmentReloadResponse(new EnvironmentReloadNotSupportedException()); | ||
| Logger.LogTrace("App payload uses an older version of Microsoft.Azure.Functions.Worker SDK which does not support placeholder."); | ||
| var e = new EnvironmentReloadNotSupportedException("This app is not using the latest version of Microsoft.Azure.Functions.Worker SDK and therefore does not leverage all performance optimizations. See https://aka.ms/azure-functions/dotnet/placeholders for more information."); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may not be super-important for this scenario, but there won't be a StackTrace with this without throwing it, will there? You can throw/catch the exception to capture the StackTrace correctly. |
||
| responseMessage.FunctionEnvironmentReloadResponse = BuildFailedEnvironmentReloadResponse(e); | ||
| break; | ||
| } | ||
|
|
||
|
|
@@ -98,27 +100,37 @@ private async Task Process(StreamingMessage msg) | |
| } | ||
| } | ||
|
|
||
| private static FunctionEnvironmentReloadResponse BuildFailedEnvironmentReloadResponse(Exception exception) | ||
| private static FunctionEnvironmentReloadResponse BuildFailedEnvironmentReloadResponse(Exception? exception = null) | ||
| { | ||
| var rpcException = new RpcException | ||
| { | ||
| Message = exception.ToString(), | ||
| Source = exception.Source ?? string.Empty, | ||
| StackTrace = exception.StackTrace ?? string.Empty | ||
| }; | ||
|
|
||
| var response = new FunctionEnvironmentReloadResponse | ||
| { | ||
| Result = new StatusResult | ||
| { | ||
| Status = StatusResult.Types.Status.Failure, | ||
| Exception = rpcException | ||
| Status = StatusResult.Types.Status.Failure | ||
| } | ||
| }; | ||
|
|
||
| response.Result.Exception = ToUserRpcException(exception); | ||
|
|
||
| return response; | ||
| } | ||
|
|
||
| internal static RpcException? ToUserRpcException(Exception? exception) | ||
| { | ||
| if (exception is null) | ||
| { | ||
| return null; | ||
| } | ||
|
|
||
| return new RpcException | ||
| { | ||
| Message = exception.Message, | ||
| Source = exception.Source ?? string.Empty, | ||
| StackTrace = exception.StackTrace ?? string.Empty, | ||
| Type = exception.GetType().FullName ?? string.Empty, | ||
| IsUserException = true | ||
| }; | ||
| } | ||
| private static FunctionMetadataResponse BuildFunctionMetadataResponse() | ||
| { | ||
| var metadataResponse = new FunctionMetadataResponse | ||
|
|
@@ -136,6 +148,7 @@ private static WorkerInitResponse BuildWorkerInitResponse() | |
| { | ||
| Result = new StatusResult { Status = StatusResult.Types.Status.Success } | ||
| }; | ||
| response.Capabilities[WorkerCapabilities.EnableUserCodeException] = bool.TrueString; | ||
|
|
||
| return response; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
|
||
| namespace FunctionsNetHost.Grpc | ||
| { | ||
| internal static class WorkerCapabilities | ||
| { | ||
| internal const string EnableUserCodeException = "EnableUserCodeException"; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
| <id>Microsoft.Azure.Functions.DotNetIsolatedNativeHost</id> | ||
| <title>Microsoft Azure Functions dotnet-isolated native host</title> | ||
| <tags>dotnet-isolated azure-functions azure</tags> | ||
| <version>1.0.1</version> | ||
| <version>1.0.2</version> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had we released 1.0.1 already? |
||
| <authors>Microsoft</authors> | ||
| <owners>Microsoft</owners> | ||
| <projectUrl>https://github.com/Azure/azure-functions-dotnet-worker</projectUrl> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.