Skip to content

Implement changes needed in the Host to decouple workers from the Host release #11111

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

Open
wants to merge 62 commits into
base: feature/decouple-workers
Choose a base branch
from

Conversation

surgupta-msft
Copy link
Contributor

@surgupta-msft surgupta-msft commented Jun 9, 2025

Issue describing the changes in this PR

resolves #10944

Update - working with Brett on addressing the comment - #11111 (comment).

Pull request checklist

IMPORTANT: Currently, changes must be backported to the in-proc branch to be included in Core Tools and non-Flex deployments.

  • Backporting to the in-proc branch is not required
    • Otherwise: Link to backporting PR
  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • My changes do not require diagnostic events changes
    • Otherwise: I have added/updated all related diagnostic events and their documentation (Documentation issue linked to PR)
  • I have added all required tests (Unit tests, E2E tests)

Additional information

Additional PR information

This pull request introduces changes to decouple language workers from the Host release and enable dynamic worker resolution. Key updates include new worker configuration resolvers, environment enhancements, and feature flags to control worker behavior.

Backlog issues - Link
Design doc - Link

Flows covered in this PR -

  1. LanguageWorkerOptionsSetup -
    • Uses IWorkerConfigurationResolverFactory to handle the instantiation logic of the resolver depending on if the feature is enabled.
    • Creates and sends an instance of IWorkerConfigurationResolver when creating an instance of RPCWorkerConfigFactory.
  2. RPCWorkerConfigFactory -
    • Calls GetWorkerConfigs() method of IWorkerConfigurationResolver to get the required worker configs.
    • Moved some methods to WorkerConfigurationHelper.cs to enable reusing of workers profile evaluation logic.
  3. Resolving Worker Configurations -
    • Added DefaultWorkerConfigurationResolver to scan the Host's "workers" directory for worker configurations.
    • Introduced DynamicWorkerConfigurationResolver, which dynamically resolves worker configurations based on -
      • Environment settings and probing paths
      • Host-Worker compatibility check
      • Leveraging Release channel concept to point to a previous version of the worker
      • Fallback to the old flow if worker is not found at the probing path level
  4. Environment Updates -
    • Added IsWindowsEnvironment() to determine the windows environment type.
    • Added IsDynamicWorkerResolutionEnabled method to EnvironmentExtensions class to enable/disable dynamic worker resolution using feature flag and hosting configuration.
    • Added a new feature flag FeatureFlagDisableWorkerProbingPaths to disable dynamic resolution feature by users.

Note: The decoupling workers flow is disabled by default in this PR. We will enable the flow after completing other relevant backlog items which will be included in follow-up PRs.

@surgupta-msft surgupta-msft requested a review from a team as a code owner June 9, 2025 19:38
@@ -144,30 +176,16 @@ internal void AddProvider(string workerDir)

_logger.LogDebug("Found worker config: {workerConfigPath}", workerConfigPath);

var workerConfig = GetWorkerConfigJsonElement(workerConfigPath);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change in logic for this line. Just moved the method GetWorkerConfigJsonElement() to class WorkerConfigurationHelper

@@ -144,30 +176,16 @@ internal void AddProvider(string workerDir)

_logger.LogDebug("Found worker config: {workerConfigPath}", workerConfigPath);

var workerConfig = GetWorkerConfigJsonElement(workerConfigPath);
var workerDescriptionElement = workerConfig.GetProperty(WorkerConstants.WorkerDescription);
Copy link
Contributor Author

@surgupta-msft surgupta-msft Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these lines (148-170) are moved to a method WorkerConfigurationHelper.GetWorkerDescription() - https://gist.github.com/surgupta-msft/b416af7ca3c8794849832cc56f7a11de/revisions

@@ -213,61 +231,6 @@ internal void AddProvider(string workerDir)
}
}

private static JsonElement GetWorkerConfigJsonElement(string workerConfigPath)
Copy link
Contributor Author

@surgupta-msft surgupta-msft Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These methods are also moved to class WorkerConfigurationHelper as we will need to call these methods from class WorkerConfigurationResolver as part of compatibility check

namespace Microsoft.Azure.WebJobs.Script.Workers.Rpc.Configuration
{
internal static class WorkerConfigurationHelper
{
Copy link
Contributor Author

@surgupta-msft surgupta-msft Jun 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the methods in this class are taken from RPCWorkerConfigFactory with minor adjustments. See gist - https://gist.github.com/surgupta-msft/7eee560448e21ad1d450eb3e425895cd/revisions

@surgupta-msft surgupta-msft changed the base branch from dev to surgupta/decouple-workers-feature June 11, 2025 05:39
@liliankasem
Copy link
Member

Minor comment on branch name, we should use feature/ for feature branches as we have rules and CI setup for it (its protected) i.e. feature/decouple-workers

@surgupta-msft surgupta-msft changed the base branch from surgupta/decouple-workers-feature to feature/decouple-workers July 8, 2025 01:16
private readonly ILogger _logger;
private readonly IConfiguration _configuration;

public DefaultWorkerConfigurationResolver(IConfiguration configuration, ILogger logger)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed some of this in the first pass -- but we're trying to move away from passing in IConfiguration or IEnvironment to any classes. They aren't very descriptive -- like right here you have no idea as a consumer what part of IConfiguration is needed.

Instead, using some kind of IOptions<> object that builds the options (using IConfiguration) before passing them in is a much nicer contract and much easier to test/read.

Highly recommend moving away from this where you can. I'll call out some others as I see them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it works, I would prefer to address this issue in a separate PR. I have created an issue - #11185 for it and added it to the "Decoupling workers" milestone. This PR already contains a lot of logic and tests and it is also against a feature branch, so I am not merging changes into dev.

However, if you are really concerned about it, I can raise another PR with the fix targeting this PR branch (surgupta/decoupling-workers). We can merge that PR first before completing this one. Though it is not my preferred approach, as this PR is becoming long-standing and we are already using this pattern in multiple places in Host code, but I can do it if necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline. Will be implementing the improvement first.

Copy link
Member

@kshyju kshyju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add the placeholder + specialization use case test to validate that flow.

@surgupta-msft
Copy link
Contributor Author

Let's also add the placeholder + specialization use case test to validate that flow.

Yes, this will definitely be included with Integration and E2E tests changes. I am currently working on it - #11140

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement changes needed in the Host to decouple workers from the Host release
5 participants