Skip to content

Commit

Permalink
Do not start language worker process if in-proc (#10161)
Browse files Browse the repository at this point in the history
  • Loading branch information
liliankasem committed May 14, 2024
1 parent 38b533c commit c6365fd
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
3 changes: 2 additions & 1 deletion release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
- Update PowerShell worker 7.2 to [4.0.3220](https://github.com/Azure/azure-functions-powershell-worker/releases/tag/v4.0.3220)
- Update PowerShell worker 7.4 to [4.0.3219](https://github.com/Azure/azure-functions-powershell-worker/releases/tag/v4.0.3219)
- Ensuring proxies are disabled, with a warning, when running in Flex Consumption.
- Fixed an issue leading to a race when invocation responses returned prior to HTTP requests being sent in proxied scenarios.
- Fixed an issue leading to a race when invocation responses returned prior to HTTP requests being sent in proxied scenarios.
- Language worker channels will not be started during placeholder mode if we are in-process (#10161)
14 changes: 13 additions & 1 deletion src/WebJobs.Script/Environment/EnvironmentExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -614,13 +614,25 @@ public static HashSet<string> GetLanguageWorkerListToStartInPlaceholder(this IEn
string placeholderList = environment.GetEnvironmentVariableOrDefault(RpcWorkerConstants.FunctionWorkerPlaceholderModeListSettingName, string.Empty);
var placeholderRuntimeSet = new HashSet<string>(placeholderList.Trim().Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim()));
string workerRuntime = environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeSettingName);
if (!string.IsNullOrEmpty(workerRuntime))

if (!environment.IsInProc(workerRuntime))
{
placeholderRuntimeSet.Add(workerRuntime);
}

return placeholderRuntimeSet;
}

public static bool IsInProc(this IEnvironment environment, string workerRuntime = null)
{
if (workerRuntime is null)
{
workerRuntime = environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeSettingName);
}

return string.IsNullOrEmpty(workerRuntime) || string.Equals(workerRuntime, RpcWorkerConstants.DotNetLanguageWorkerName, StringComparison.OrdinalIgnoreCase);
}

public static bool IsApplicationInsightsAgentEnabled(this IEnvironment environment)
{
// cache the value of the environment variable
Expand Down
32 changes: 32 additions & 0 deletions test/WebJobs.Script.Tests/Extensions/EnvironmentExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -454,5 +454,37 @@ public void AzureFilesAppSettingsExist_ReturnsExpectedResult(string connectionSt
environment.SetEnvironmentVariable(AzureFilesContentShare, contentShare);
Assert.Equal(expected, environment.AzureFilesAppSettingsExist());
}

[Theory]
[InlineData(null, true)]
[InlineData("", true)]
[InlineData("dotnet", true)]
[InlineData("dotnet-isolated", false)]
[InlineData("java", false)]
[InlineData("python", false)]
[InlineData("node", false)]
public void IsInProc_ReturnsExpectedResult(string value, bool expected)
{
var environment = new TestEnvironment();
if (value != null)
{
environment.SetEnvironmentVariable(FunctionWorkerRuntime, value);
}
Assert.Equal(expected, environment.IsInProc());
}

[Theory]
[InlineData(null, true)]
[InlineData("", true)]
[InlineData("dotnet", true)]
[InlineData("dotnet-isolated", false)]
[InlineData("java", false)]
[InlineData("python", false)]
[InlineData("node", false)]
public void IsInProc_WithRuntimeParameter_ReturnsExpectedResult(string value, bool expected)
{
var environment = new TestEnvironment();
Assert.Equal(expected, environment.IsInProc(value));
}
}
}

0 comments on commit c6365fd

Please sign in to comment.