Skip to content

Commit c6365fd

Browse files
authored
Do not start language worker process if in-proc (#10161)
1 parent 38b533c commit c6365fd

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

release_notes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
- Update PowerShell worker 7.2 to [4.0.3220](https://github.com/Azure/azure-functions-powershell-worker/releases/tag/v4.0.3220)
1414
- Update PowerShell worker 7.4 to [4.0.3219](https://github.com/Azure/azure-functions-powershell-worker/releases/tag/v4.0.3219)
1515
- Ensuring proxies are disabled, with a warning, when running in Flex Consumption.
16-
- Fixed an issue leading to a race when invocation responses returned prior to HTTP requests being sent in proxied scenarios.
16+
- Fixed an issue leading to a race when invocation responses returned prior to HTTP requests being sent in proxied scenarios.
17+
- Language worker channels will not be started during placeholder mode if we are in-process (#10161)

src/WebJobs.Script/Environment/EnvironmentExtensions.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,13 +614,25 @@ public static HashSet<string> GetLanguageWorkerListToStartInPlaceholder(this IEn
614614
string placeholderList = environment.GetEnvironmentVariableOrDefault(RpcWorkerConstants.FunctionWorkerPlaceholderModeListSettingName, string.Empty);
615615
var placeholderRuntimeSet = new HashSet<string>(placeholderList.Trim().Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim()));
616616
string workerRuntime = environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeSettingName);
617-
if (!string.IsNullOrEmpty(workerRuntime))
617+
618+
if (!environment.IsInProc(workerRuntime))
618619
{
619620
placeholderRuntimeSet.Add(workerRuntime);
620621
}
622+
621623
return placeholderRuntimeSet;
622624
}
623625

626+
public static bool IsInProc(this IEnvironment environment, string workerRuntime = null)
627+
{
628+
if (workerRuntime is null)
629+
{
630+
workerRuntime = environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeSettingName);
631+
}
632+
633+
return string.IsNullOrEmpty(workerRuntime) || string.Equals(workerRuntime, RpcWorkerConstants.DotNetLanguageWorkerName, StringComparison.OrdinalIgnoreCase);
634+
}
635+
624636
public static bool IsApplicationInsightsAgentEnabled(this IEnvironment environment)
625637
{
626638
// cache the value of the environment variable

test/WebJobs.Script.Tests/Extensions/EnvironmentExtensionsTests.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,5 +454,37 @@ public void AzureFilesAppSettingsExist_ReturnsExpectedResult(string connectionSt
454454
environment.SetEnvironmentVariable(AzureFilesContentShare, contentShare);
455455
Assert.Equal(expected, environment.AzureFilesAppSettingsExist());
456456
}
457+
458+
[Theory]
459+
[InlineData(null, true)]
460+
[InlineData("", true)]
461+
[InlineData("dotnet", true)]
462+
[InlineData("dotnet-isolated", false)]
463+
[InlineData("java", false)]
464+
[InlineData("python", false)]
465+
[InlineData("node", false)]
466+
public void IsInProc_ReturnsExpectedResult(string value, bool expected)
467+
{
468+
var environment = new TestEnvironment();
469+
if (value != null)
470+
{
471+
environment.SetEnvironmentVariable(FunctionWorkerRuntime, value);
472+
}
473+
Assert.Equal(expected, environment.IsInProc());
474+
}
475+
476+
[Theory]
477+
[InlineData(null, true)]
478+
[InlineData("", true)]
479+
[InlineData("dotnet", true)]
480+
[InlineData("dotnet-isolated", false)]
481+
[InlineData("java", false)]
482+
[InlineData("python", false)]
483+
[InlineData("node", false)]
484+
public void IsInProc_WithRuntimeParameter_ReturnsExpectedResult(string value, bool expected)
485+
{
486+
var environment = new TestEnvironment();
487+
Assert.Equal(expected, environment.IsInProc(value));
488+
}
457489
}
458490
}

0 commit comments

Comments
 (0)