Skip to content

Commit bbb8762

Browse files
authored
RpcInitialization service should ignore workerRuntime case (#5012)
1 parent 8e3087e commit bbb8762

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

src/WebJobs.Script/Rpc/RpcInitializationService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ private Task InitializePlaceholderChannelsAsync(OSPlatform os)
153153

154154
private Task InitializeWebHostRuntimeChannelsAsync()
155155
{
156-
if (_webHostLevelWhitelistedRuntimes.Contains(_workerRuntime))
156+
if (_webHostLevelWhitelistedRuntimes.Contains(_workerRuntime, StringComparer.OrdinalIgnoreCase))
157157
{
158158
return _webHostlanguageWorkerChannelManager.InitializeChannelAsync(_workerRuntime);
159159
}
@@ -180,7 +180,7 @@ internal bool ShouldStartAsPlaceholderPool()
180180
// We are in placeholder mode but a worker runtime IS set
181181
return _environment.IsPlaceholderModeEnabled()
182182
&& !string.IsNullOrEmpty(_workerRuntime)
183-
&& _placeholderPoolWhitelistedRuntimes.Contains(_workerRuntime);
183+
&& _placeholderPoolWhitelistedRuntimes.Contains(_workerRuntime, StringComparer.OrdinalIgnoreCase);
184184
}
185185

186186
// To help with unit tests

src/WebJobs.Script/Rpc/WebHostLanguageWorkerChannelManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class WebHostLanguageWorkerChannelManager : IWebHostLanguageWorkerChannel
2626
private string _workerRuntime;
2727
private Action _shutdownStandbyWorkerChannels;
2828

29-
private ConcurrentDictionary<string, Dictionary<string, TaskCompletionSource<ILanguageWorkerChannel>>> _workerChannels = new ConcurrentDictionary<string, Dictionary<string, TaskCompletionSource<ILanguageWorkerChannel>>>();
29+
private ConcurrentDictionary<string, Dictionary<string, TaskCompletionSource<ILanguageWorkerChannel>>> _workerChannels = new ConcurrentDictionary<string, Dictionary<string, TaskCompletionSource<ILanguageWorkerChannel>>>(StringComparer.OrdinalIgnoreCase);
3030

3131
public WebHostLanguageWorkerChannelManager(IScriptEventManager eventManager, IEnvironment environment, ILoggerFactory loggerFactory, ILanguageWorkerChannelFactory languageWorkerChannelFactory, IOptionsMonitor<ScriptApplicationHostOptions> applicationHostOptions)
3232
{
@@ -129,7 +129,7 @@ private bool UsePlaceholderChannel(string workerRuntime)
129129
{
130130
// Special case: node apps must be read-only to use the placeholder mode channel
131131
// TODO: Remove special casing when resolving https://github.com/Azure/azure-functions-host/issues/4534
132-
if (string.Equals(workerRuntime, LanguageWorkerConstants.NodeLanguageWorkerName))
132+
if (string.Equals(workerRuntime, LanguageWorkerConstants.NodeLanguageWorkerName, StringComparison.OrdinalIgnoreCase))
133133
{
134134
return _environment.FileSystemIsReadOnly();
135135
}

test/WebJobs.Script.Tests/Rpc/RpcInitializationServiceTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,10 @@ public void ShouldStartStandbyPlaceholderChannels_Returns_ExpectedValue(string p
309309
[InlineData("1", "node", "1234", true)]
310310
[InlineData("0", "node", "1234", false)]
311311
[InlineData("1", "node", "", true)]
312+
[InlineData("1", "Node", "", true)]
312313
[InlineData("1", "java", "1234", true)]
313314
[InlineData("0", "java", "1234", false)]
315+
[InlineData("0", "JAVA", "1234", false)]
314316
[InlineData("1", "java", "", true)]
315317
[InlineData("1", "", "1234", false)]
316318
[InlineData("1", "dotnet", "1234", false)]

test/WebJobs.Script.Tests/Rpc/WebHostLanguageWorkerChannelManagerTests.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,12 @@ public async Task ShutdownStandyChannels_WorkerRuntime_Node_Set()
148148
Assert.Null(initializedChannel);
149149
}
150150

151-
[Fact]
152-
public async Task SpecializeAsync_Node_ReadOnly_KeepsProcessAlive()
151+
[Theory]
152+
[InlineData("nOde")]
153+
[InlineData("Node")]
154+
public async Task SpecializeAsync_Node_ReadOnly_KeepsProcessAlive(string runtime)
153155
{
154-
_testEnvironment.SetEnvironmentVariable(LanguageWorkerConstants.FunctionWorkerRuntimeSettingName, LanguageWorkerConstants.NodeLanguageWorkerName);
156+
_testEnvironment.SetEnvironmentVariable(LanguageWorkerConstants.FunctionWorkerRuntimeSettingName, runtime);
155157
_testEnvironment.SetEnvironmentVariable(EnvironmentSettingNames.AzureWebsiteZipDeployment, "1");
156158

157159
_languageWorkerChannelManager = new WebHostLanguageWorkerChannelManager(_eventManager, _testEnvironment, _loggerFactory, _languageWorkerChannelFactory, _optionsMonitor);

0 commit comments

Comments
 (0)