-
Notifications
You must be signed in to change notification settings - Fork 204
Improved handling of env reload request - handles older version of worker sdk #1955
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
34b08ce
Handling specialization not supported case.
kshyju 169f6e6
Handling older worker version for environment reload request.
kshyju 2901c79
Fix application path.
kshyju 3e05c5c
package version bump
kshyju 0518ec6
PR feedback:
kshyju 62fc978
PR feedback - type renames as suggested.
kshyju File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
host/src/FunctionsNetHost/Grpc/Exceptions/EnvironmentReloadNotSupportedException.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
|
||
| namespace Microsoft.Azure.Functions.Worker | ||
| { | ||
| /// <summary> | ||
| /// The exception that is thrown when the current function app payload does not support environment reload. | ||
| /// </summary> | ||
| public sealed class EnvironmentReloadNotSupportedException : NotSupportedException | ||
| { | ||
| public EnvironmentReloadNotSupportedException() { } | ||
|
|
||
| public EnvironmentReloadNotSupportedException(string message) : base(message) { } | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
host/src/FunctionsNetHost/Grpc/Exceptions/FunctionAppPayloadNotFoundException.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
|
||
| namespace Microsoft.Azure.Functions.Worker | ||
| { | ||
| /// <summary> | ||
| /// The exception that is thrown when there is no function app payload found. | ||
| /// </summary> | ||
| public sealed class FunctionAppPayloadNotFoundException : Exception | ||
| { | ||
| public FunctionAppPayloadNotFoundException() { } | ||
|
|
||
| public FunctionAppPayloadNotFoundException(string message) : base(message) { } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
host/src/FunctionsNetHost/Grpc/WorkerConfig/WorkerConfig.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // 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 | ||
| { | ||
| /// <summary> | ||
| /// Represents a worker configuration instance. | ||
| /// </summary> | ||
| public sealed class WorkerConfig | ||
| { | ||
| public WorkerDescription? Description { set; get; } | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
host/src/FunctionsNetHost/Grpc/WorkerConfig/WorkerConfigSerializerContext.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
|
||
| using System.Text.Json.Serialization; | ||
|
|
||
| namespace FunctionsNetHost.Grpc | ||
| { | ||
| [JsonSerializable(typeof(WorkerConfig))] | ||
| [JsonSourceGenerationOptions(IncludeFields = true, PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)] | ||
| internal partial class WorkerConfigSerializerContext : JsonSerializerContext { } | ||
| } |
39 changes: 39 additions & 0 deletions
39
host/src/FunctionsNetHost/Grpc/WorkerConfig/WorkerConfigUtils.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // Copyright (c) .NET Foundation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
|
||
| using System.Text.Json; | ||
|
|
||
| namespace FunctionsNetHost.Grpc | ||
| { | ||
| internal static class WorkerConfigUtils | ||
| { | ||
| /// <summary> | ||
| /// Builds and returns an instance of <see cref="WorkerConfig"/> from the worker.config.json file if present in the application directory. | ||
| /// </summary> | ||
| /// <param name="applicationDirectory">The directory where function app deployed payload is present.</param> | ||
| internal static async Task<WorkerConfig?> GetWorkerConfig(string applicationDirectory) | ||
| { | ||
| string workerConfigPath = string.Empty; | ||
|
|
||
| try | ||
| { | ||
| workerConfigPath = Path.Combine(applicationDirectory, "worker.config.json"); | ||
|
|
||
| using Stream stream = File.OpenRead(workerConfigPath); | ||
| var workerConfig = await JsonSerializer.DeserializeAsync(stream, WorkerConfigSerializerContext.Default.WorkerConfig); | ||
|
|
||
| return workerConfig; | ||
| } | ||
| catch (FileNotFoundException) | ||
| { | ||
| Logger.Log($"worker.config.json not found at {workerConfigPath}. This may indicate missing app payload."); | ||
| return null; | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| Logger.Log($"Error in WorkerConfigUtils.GetWorkerConfig.{ex}"); | ||
|
kshyju marked this conversation as resolved.
|
||
| return null; | ||
| } | ||
| } | ||
| } | ||
| } | ||
12 changes: 12 additions & 0 deletions
12
host/src/FunctionsNetHost/Grpc/WorkerConfig/WorkerDescription.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // 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 | ||
| { | ||
| public sealed class WorkerDescription | ||
| { | ||
| public string? DefaultWorkerPath { set; get; } | ||
|
|
||
| public bool CanUsePlaceholder { set; get; } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.