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

Draft
wants to merge 69 commits into
base: feature/decouple-workers
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
987fad0
Changes for Decoupling workers implementation
surgupta-msft May 25, 2025
734b029
Added test data for unit tests
surgupta-msft May 26, 2025
cefdb92
Code cleanup and adding comments
surgupta-msft May 26, 2025
021ac3e
Code refactoring to check probing paths enabled only once
surgupta-msft May 26, 2025
36abb61
Code refactoring
surgupta-msft May 26, 2025
8929697
Tests cleanup
surgupta-msft May 26, 2025
1588711
Added test for LanguageWorkerOptionsSetup
surgupta-msft May 26, 2025
2606f37
Adding Tests for Utility class
surgupta-msft May 27, 2025
08850c9
Adding more tests
surgupta-msft May 27, 2025
10d2e52
Changes in Tests
surgupta-msft May 27, 2025
95af17e
Updating LanguageWorkerOptionsSetupTests
surgupta-msft May 27, 2025
150aaf3
Minor refactoring and code cleanup
surgupta-msft May 27, 2025
0def600
Fixing build warning
surgupta-msft May 27, 2025
cc3e044
Fixing build issue in tests
surgupta-msft May 27, 2025
26e8580
Unit test fixing
surgupta-msft May 27, 2025
9b6a945
Stylecop fixes
surgupta-msft Jun 2, 2025
e90ddda
Merge branch 'dev' into surgupta/decoupling-workers
surgupta-msft Jun 2, 2025
ee60ec4
Test data cleanup
surgupta-msft Jun 6, 2025
1495f31
Test data cleanup
surgupta-msft Jun 6, 2025
c2628bb
Merge branch 'dev' into surgupta/decoupling-workers
surgupta-msft Jun 8, 2025
4ee497b
Updated release notes
surgupta-msft Jun 9, 2025
c85ced3
Merge branch 'surgupta/decouple-workers-feature' into surgupta/decoup…
surgupta-msft Jun 12, 2025
5168090
Renaming feature name
surgupta-msft Jun 12, 2025
1ad3d14
Updated tests
surgupta-msft Jun 12, 2025
d67a254
logging update
surgupta-msft Jun 13, 2025
5844053
Logging update
surgupta-msft Jun 13, 2025
3bf3f79
Placeholder mode check
surgupta-msft Jun 14, 2025
1171fe8
Handling DefaultWorkerPath update scenario
surgupta-msft Jun 15, 2025
bf573b5
Rebasing with dev branch
surgupta-msft Jun 16, 2025
3bdc8e1
Tests update after logs changes
surgupta-msft Jun 17, 2025
f4a162a
Rebase with main
surgupta-msft Jun 17, 2025
d49ace8
Merge with main
surgupta-msft Jun 20, 2025
ed80fd1
Logs and Tests updates
surgupta-msft Jun 22, 2025
dd70dfc
Addressed PR feedback
surgupta-msft Jun 25, 2025
bd009fd
Merge with main
surgupta-msft Jun 25, 2025
2a56550
Corrected method return value
surgupta-msft Jun 25, 2025
2c7b9ef
Addressing PR feedback
surgupta-msft Jun 27, 2025
1d29846
Merge branch 'dev' into surgupta/decoupling-workers
surgupta-msft Jun 27, 2025
03d49c0
Addressed PR feedback
surgupta-msft Jun 28, 2025
6a94387
Using IFileSystem instead of System.Directory
surgupta-msft Jun 29, 2025
275831c
Addressing PR feedback. Updating method to get versions in descending…
surgupta-msft Jun 30, 2025
f0a30ae
Getting parent directory for windows probing path
surgupta-msft Jul 1, 2025
f92c521
Refactored code and introduced static and dynamic worker config resol…
surgupta-msft Jul 2, 2025
ace597c
Merge with main branch
surgupta-msft Jul 2, 2025
bf3d126
code cleanup
surgupta-msft Jul 3, 2025
9e4b960
Code cleanup and added more comments
surgupta-msft Jul 3, 2025
2585946
Adding condition if worker.config is empty
surgupta-msft Jul 3, 2025
3c55d1d
Addressed PR feedback and code refactoring
surgupta-msft Jul 5, 2025
c5a1b0f
Creating WorkerConfigurationResolverFactory
surgupta-msft Jul 6, 2025
6449065
code cleanup
surgupta-msft Jul 6, 2025
5ad1699
Minor code refactoring
surgupta-msft Jul 6, 2025
d15984c
Code cleanup and addressing PR feedback
surgupta-msft Jul 7, 2025
c6b9e93
Test folder update
surgupta-msft Jul 8, 2025
be527c4
Test folder name update
surgupta-msft Jul 8, 2025
aaf5243
Merge with main
surgupta-msft Jul 8, 2025
e0cb000
Added some code comments
surgupta-msft Jul 8, 2025
738cea9
Addressing PR feedback
surgupta-msft Jul 9, 2025
710ae35
Log improvement
surgupta-msft Jul 9, 2025
90e0ad2
Condition update to include placeholder mode
surgupta-msft Jul 12, 2025
b3a4045
Merge with main
surgupta-msft Jul 12, 2025
fbb3c10
Test fix
surgupta-msft Jul 15, 2025
2936fa8
Merge with main
surgupta-msft Jul 18, 2025
9f1a9af
Improve WorkerConfigurationResolver to leverage Options pattern (#11203)
surgupta-msft Jul 28, 2025
3825893
Rebase with main
surgupta-msft Jul 28, 2025
3681e57
Merge branch 'surgupta/decoupling-workers' of https://github.com/Azur…
surgupta-msft Jul 28, 2025
2c2e8e3
code cleanup and added comments in resolver options class
surgupta-msft Jul 28, 2025
779fd2d
Using Options to check if Dynamic worker resolution is enabled
surgupta-msft Jul 29, 2025
4e03f80
Tests cleanup
surgupta-msft Jul 29, 2025
e184c4f
Added WorkerConfigurationResolverOptionsSetupTests
surgupta-msft Jul 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
- Handles loading extensions.json with empty extensions(#11174)
- Update HttpWorkerOptions to implement IOptionsFormatter (#11175)
- Improved metadata binding validation (#11101)
- Implement changes needed in the Host to decouple workers from the Host release (#11111)
11 changes: 11 additions & 0 deletions src/WebJobs.Script/Config/FunctionsHostingConfigOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ internal string WorkerIndexingDisabledApps
}
}

/// <summary>
/// Gets a string delimited by '|' that contains the names of the language workers available through probing paths outside of the Host.
/// </summary>
internal string WorkersAvailableForDynamicResolution
{
get
{
return GetFeature(RpcWorkerConstants.WorkersAvailableForDynamicResolution) ?? string.Empty;
}
}

/// <summary>
/// Gets a value indicating whether Linux Log Backoff is disabled in the hosting config.
/// </summary>
Expand Down
46 changes: 46 additions & 0 deletions src/WebJobs.Script/Environment/EnvironmentExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,16 @@ public static bool IsWindowsElasticPremium(this IEnvironment environment)
return string.Equals(value, ScriptConstants.ElasticPremiumSku, StringComparison.OrdinalIgnoreCase);
}

/// <summary>
/// Gets a value indicating whether the application is running in a Windows App Service environment.
/// </summary>
/// <param name="environment">The environment to verify.</param>
/// <returns><see cref="true"/> if running in a Windows App Service app; otherwise, false.</returns>
public static bool IsWindowsEnvironment(this IEnvironment environment)
{
return environment.IsWindowsAzureManagedHosting() || environment.IsWindowsConsumption() || environment.IsWindowsElasticPremium();
}

public static bool IsDynamicSku(this IEnvironment environment)
{
return environment.IsConsumptionSku() || environment.IsWindowsElasticPremium();
Expand Down Expand Up @@ -687,6 +697,42 @@ public static bool IsInProc(this IEnvironment environment, string workerRuntime
return string.IsNullOrEmpty(workerRuntime) || string.Equals(workerRuntime, RpcWorkerConstants.DotNetLanguageWorkerName, StringComparison.OrdinalIgnoreCase);
}

public static string GetPlatformReleaseChannel(this IEnvironment environment)
{
return environment.GetEnvironmentVariable(AntaresPlatformReleaseChannel) ?? ScriptConstants.LatestPlatformChannelNameUpper;
}

/// <summary>
/// Checks if the Dynamic Worker Resolution feature is disabled via feature flag.
/// Returns true if the feature is disabled, false otherwise.
/// </summary>
public static bool IsWorkerResolutionFeatureDisabled(this IEnvironment environment)
{
return FeatureFlags.IsEnabled(ScriptConstants.FeatureFlagDisableDynamicWorkerResolution, environment);
}

// Users can disable dynamic worker resolution via setting the appropriate feature flag.
// Worker resolution can be enabled for specific workers at the stamp level via hosting config options.
// Feature flag takes precedence over hosting config options.
public static bool IsDynamicWorkerResolutionEnabled(this IEnvironment environment, HashSet<string> workersAvailableForResolutionViaHostingConfig)
{
if (environment.IsWorkerResolutionFeatureDisabled() || workersAvailableForResolutionViaHostingConfig is null)
{
return false;
}

string workerRuntime = environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeSettingName);

if (!environment.IsMultiLanguageRuntimeEnvironment() &&
!string.IsNullOrWhiteSpace(workerRuntime) &&
!environment.IsPlaceholderModeEnabled())
{
return workersAvailableForResolutionViaHostingConfig.Contains(workerRuntime);
}

return workersAvailableForResolutionViaHostingConfig.Any();
}

public static bool IsApplicationInsightsAgentEnabled(this IEnvironment environment)
{
// cache the value of the environment variable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static class EnvironmentSettingNames
public const string AppInsightsAgent = "APPLICATIONINSIGHTS_ENABLE_AGENT";
public const string FunctionsExtensionVersion = "FUNCTIONS_EXTENSION_VERSION";
public const string FunctionWorkerRuntime = "FUNCTIONS_WORKER_RUNTIME";
public const string WorkerProbingPaths = "WORKER_PROBING_PATHS";
public const string ContainerName = "CONTAINER_NAME";
public const string WebsitePodName = "WEBSITE_POD_NAME";
public const string LegionServiceHost = "LEGION_SERVICE_HOST";
Expand Down
3 changes: 3 additions & 0 deletions src/WebJobs.Script/ScriptConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using NuGet.Versioning;

Expand Down Expand Up @@ -132,6 +133,7 @@ public static class ScriptConstants
public const string FeatureFlagDisableWebHostLogForwarding = "DisableWebHostLogForwarding";
public const string FeatureFlagDisableMergedWebHostScriptHostConfiguration = "DisableMergedConfiguration";
public const string FeatureFlagEnableWorkerIndexing = "EnableWorkerIndexing";
public const string FeatureFlagDisableDynamicWorkerResolution = "DisableDynamicWorkerResolution";
public const string FeatureFlagEnableDebugTracing = "EnableDebugTracing";
public const string FeatureFlagEnableProxies = "EnableProxies";
public const string FeatureFlagStrictHISModeEnabled = "StrictHISModeEnabled";
Expand Down Expand Up @@ -247,6 +249,7 @@ public static class ScriptConstants
public static readonly long DefaultMaxRequestBodySize = 104857600;

public static readonly ImmutableArray<string> SystemLogCategoryPrefixes = ImmutableArray.Create("Microsoft.Azure.WebJobs.", "Function.", "Worker.", "Host.");
public static readonly HashSet<string> HostCapabilities = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

public static readonly string FunctionMetadataDirectTypeKey = "DirectType";
public static readonly string LiveLogsSessionAIKey = "#AzFuncLiveLogsSessionId";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace Microsoft.Azure.WebJobs.Script.Workers.Rpc.Configuration
{
// This class resolves worker configurations by scanning the "workers" directory within the Host for worker config files.
internal sealed class DefaultWorkerConfigurationResolver : IWorkerConfigurationResolver
{
private readonly ILogger _logger;
private readonly IConfiguration _configuration;

public DefaultWorkerConfigurationResolver(IConfiguration configuration, ILogger logger)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
}

public List<string> GetWorkerConfigPaths()
{
var workersDirPath = WorkerConfigurationHelper.GetWorkersDirPath(_configuration);
_logger.LogDebug("Workers Directory set to: {workersDirPath}", workersDirPath);

List<string> workerConfigs = new();

foreach (var workerDir in Directory.EnumerateDirectories(workersDirPath))
{
string workerConfigPath = Path.Combine(workerDir, RpcWorkerConstants.WorkerConfigFileName);

if (File.Exists(workerConfigPath))
{
workerConfigs.Add(workerDir);
}
}

return workerConfigs;
}
}
}
Loading