-
Notifications
You must be signed in to change notification settings - Fork 466
Implementing a resolver that resolves worker configurations from specified probing paths #11258
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
base: dev
Are you sure you want to change the base?
Conversation
src/WebJobs.Script/Workers/Rpc/Configuration/WorkerConfigurationResolverOptionsSetup.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script/Workers/Rpc/Configuration/WorkerConfigurationResolverOptionsSetup.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script/Workers/Rpc/Configuration/WorkerConfigurationResolverOptionsSetup.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script/Workers/Rpc/Configuration/WorkerConfigurationResolverOptionsSetup.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script/Workers/Rpc/Configuration/WorkerConfigurationResolverOptionsSetup.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script/Workers/Rpc/Configuration/WorkerConfigurationResolverOptionsSetup.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script/Workers/Rpc/Configuration/WorkerConfigurationResolverOptionsSetup.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script/Workers/Rpc/Configuration/WorkerConfigurationResolverOptionsSetup.cs
Show resolved
Hide resolved
src/WebJobs.Script/Workers/Rpc/Configuration/WorkerConfigurationResolverOptionsSetup.cs
Show resolved
Hide resolved
src/WebJobs.Script/Workers/Rpc/Configuration/WorkerConfigurationResolverOptionsSetup.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script/Workers/Rpc/Configuration/WorkerConfigurationResolverOptionsSetup.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script/Workers/Rpc/Configuration/WorkerConfigurationResolverOptionsSetup.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script.WebHost/WebHostServiceCollectionExtensions.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script/Workers/Rpc/Configuration/WorkerConfigurationResolverOptionsSetup.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script/Workers/Rpc/Configuration/WorkerConfigurationResolverOptions.cs
Show resolved
Hide resolved
src/WebJobs.Script/Workers/Rpc/Configuration/DynamicWorkerConfigurationResolver.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script/Workers/Rpc/Configuration/DynamicWorkerConfigurationResolver.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script/Workers/Rpc/Configuration/WorkerConfigurationResolverOptionsSetup.cs
Show resolved
Hide resolved
src/WebJobs.Script/Workers/Rpc/Configuration/WorkerConfigurationResolverOptionsSetup.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a dynamic worker configuration resolver that enables language workers to be decoupled from the Host release by resolving worker configurations from specified probing paths. It introduces a new DynamicWorkerConfigurationResolver
that can dynamically discover and resolve worker configurations based on environment settings, compatibility checks, and release channel concepts, with fallback to the existing resolution mechanism.
Key changes include:
- New dynamic worker configuration resolution system with probing paths support
- Enhanced worker configuration options with environment-based settings
- Refactored shared worker configuration logic into helper classes
Reviewed Changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
DynamicWorkerConfigurationResolver.cs |
Implements the core dynamic resolution logic with probing paths, version selection, and compatibility checks |
WorkerConfigurationResolverOptionsSetup.cs |
Configures resolver options from environment variables and hosting config |
WorkerConfigurationResolverOptions.cs |
Adds new properties for dynamic resolution settings |
WorkerConfigurationHelper.cs |
Extracts shared worker description logic from RpcWorkerConfigFactory |
RpcWorkerConfigFactory.cs |
Refactored to use shared helper methods |
WebHostServiceCollectionExtensions.cs |
Adds service registration logic to choose between resolvers |
Various test files | Comprehensive test coverage for new functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/WebJobs.Script/Workers/Rpc/Configuration/WorkerConfigurationHelper.cs
Show resolved
Hide resolved
src/WebJobs.Script/Workers/Rpc/Configuration/DynamicWorkerConfigurationResolver.cs
Show resolved
Hide resolved
_fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem)); | ||
_functionsHostingConfigOptions = functionsHostingConfigOptions ?? throw new ArgumentNullException(nameof(functionsHostingConfigOptions)); | ||
ArgumentNullException.ThrowIfNull(_functionsHostingConfigOptions.Value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you shouldn't need this -- i don't think this can ever be null (dotnet will always create one when you call .Value
)
src/WebJobs.Script/Workers/Rpc/Configuration/WorkerConfigurationResolverOptionsSetup.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script/Workers/Rpc/Configuration/WorkerConfigurationResolverOptionsSetup.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script/Workers/Rpc/Configuration/WorkerConfigurationResolverOptionsSetup.cs
Outdated
Show resolved
Hide resolved
|
||
private static void GetWorkerDescriptionFromAppSettings(RpcWorkerDescription workerDescription, Dictionary<string, string> languageWorkersSettings) | ||
{ | ||
if (languageWorkersSettings.TryGetValue($"{RpcWorkerConstants.LanguageWorkersSectionName}:{workerDescription.Language}:{WorkerConstants.WorkerDescriptionDefaultExecutablePath}", out string defaultExecutablePathSetting) && defaultExecutablePathSetting is not null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we parse LanguageWorkerSettings elsewhere like i suggested, this gets simpler.
_fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem)); | ||
_profileManager = workerProfileManager ?? throw new ArgumentNullException(nameof(workerProfileManager)); | ||
_workerConfigurationResolverOptions = workerConfigResolverOptions ?? throw new ArgumentNullException(nameof(workerConfigResolverOptions)); | ||
ArgumentNullException.ThrowIfNull(workerConfigResolverOptions.CurrentValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't think this can be null -- likely don't need this
src/WebJobs.Script/Workers/Rpc/Configuration/DynamicWorkerConfigurationResolver.cs
Show resolved
Hide resolved
return false; | ||
} | ||
|
||
JsonElement workerConfigJson = WorkerConfigurationHelper.GetWorkerConfigJsonElement(workerConfigPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see us calling this from at least 2 places, meaning we're loading and parsing this json config at least twice. We should only be doing this once. Can you refactor this so it's only parsed once? Is this the same thing that's available in LanguageWorkerSettings in the Options object?
/// </summary> | ||
/// <param name="workerConfig"> Worker config: { "hostRequirements": [ "test-capability1", "test-capability2" ] }. </param> | ||
/// <returns> HashSet { "test-capability1", "test-capability2" }. </returns> | ||
private HashSet<string> GetHostRequirementsFromWorker(JsonElement workerConfig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like that we're operating on JsonElements in here -- I would think that this would be abstracted away somehow and we'd just be given the WorkerConfig as an object to work with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leaving initial notes, will continue review this afternoon
src/WebJobs.Script/Workers/Rpc/Configuration/DynamicWorkerConfigurationResolver.cs
Show resolved
Hide resolved
private readonly ILogger _logger; | ||
private readonly IWorkerProfileManager _profileManager; | ||
private readonly IFileSystem _fileSystem; | ||
private readonly JsonSerializerOptions _jsonSerializerOptions = new() { PropertyNameCaseInsensitive = true }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have global or host wide JsonSerializerOptions
we can use? I know PropertyNameCaseInsensitive = true
is used a lot throughout the repo so wondering if there is a single one to be shared instead of implementing this every time
src/WebJobs.Script/Workers/Rpc/Configuration/DynamicWorkerConfigurationResolver.cs
Outdated
Show resolved
Hide resolved
test/WebJobs.Script.Tests/Configuration/LanguageWorkerOptionsSetupTests.cs
Outdated
Show resolved
Hide resolved
} | ||
|
||
public void Configure(WorkerConfigurationResolverOptions options) | ||
{ | ||
var configuration = GetRequiredConfiguration(); | ||
options.WorkersRootDirPath = GetWorkersRootDirPath(configuration); | ||
options.WorkerRuntime = _environment.GetFunctionsWorkerRuntime(); | ||
options.ReleaseChannel = _environment.GetPlatformReleaseChannel(); | ||
options.IsPlaceholderModeEnabled = _environment.IsPlaceholderModeEnabled(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we were moving away from environment for resolving this, shouldn't this be coming from options? Or am I missing something from the discussion about this change?
Issue describing the changes in this PR
resolves #10944
Pull request checklist
IMPORTANT: Currently, changes must be backported to the
in-proc
branch to be included in Core Tools and non-Flex deployments.in-proc
branch is not requiredrelease_notes.md
Additional information
This pull request introduces changes to decouple language workers from the Host release and enable dynamic worker resolution.
Backlog issues - Link
Design doc - Link
Flows covered in this PR -
DynamicWorkerConfigurationResolver
, which dynamically resolves worker configurations based on -WorkerConfigurationHelper.cs
to enable reusing of workers profile evaluation logic between 2 resolvers.FeatureFlagDisableWorkerProbingPaths
to disable dynamic resolution feature by users.WorkerConfigurationResolverOptions
by getting required values from IConfiguration and IEnvironment such as worker probing paths, release channel, workers available for resolution via hosting config.Note: The decoupling workers flow is disabled by default in this PR. The flow can be enabled by setting the Hosting config which will be done after completing other relevant backlog items.