Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -16,3 +16,4 @@
- This fixes a bug with worker indexing where we are shutting down worker channels and creating a new channel that never
gets properly initialized as the invocation buffers are not created - this leads to a "Did not find initialized workers" error.
- Check if a blob container or table exists before trying to create it (#9555)
- Limit dotnet-isolated specialization to 64 bit host process (#9548)
7 changes: 6 additions & 1 deletion src/WebJobs.Script/Environment/IEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ namespace Microsoft.Azure.WebJobs.Script
/// </summary>
public interface IEnvironment
{
/// <summary>
/// Gets a value indicating whether the current process is a 64-bit process.
/// </summary>
public bool Is64BitProcess { get; }

/// <summary>
/// Returns the value of an environment variable for the current <see cref="IEnvironment"/>.
/// </summary>
Expand All @@ -20,7 +25,7 @@ public interface IEnvironment
string GetEnvironmentVariable(string name);

/// <summary>
/// Creates, modifies, or deletes an environment variable stored in the current <see cref="IEnvironment"/>
/// Creates, modifies, or deletes an environment variable stored in the current <see cref="IEnvironment"/>.
/// </summary>
/// <param name="name">The environment variable name.</param>
/// <param name="value">The value to assign to the variable.</param>
Expand Down
2 changes: 2 additions & 0 deletions src/WebJobs.Script/Environment/SystemEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ private SystemEnvironment()

public static SystemEnvironment Instance => _instance.Value;

public bool Is64BitProcess => Environment.Is64BitProcess;

private static SystemEnvironment CreateInstance()
{
return new SystemEnvironment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public bool IsLegacyExtensionBundle()
/// <summary>
/// Attempts to locate the extension bundle inside the probing paths and download paths. If the extension bundle is not found then it will download the extension bundle.
/// </summary>
/// <returns>Path of the extension bundle</returns>
/// <returns>Path of the extension bundle.</returns>
public async Task<string> GetExtensionBundlePath()
{
using (var httpClient = new HttpClient())
Expand All @@ -83,8 +83,8 @@ public async Task<string> GetExtensionBundlePath()
/// <summary>
/// Attempts to locate the extension bundle inside the probing paths and download paths. If the extension bundle is not found then it will download the extension bundle.
/// </summary>
/// <param name="httpClient">HttpClient used to download the extension bundle</param>
/// <returns>Path of the extension bundle</returns>
/// <param name="httpClient">HttpClient used to download the extension bundle.</param>
/// <returns>Path of the extension bundle.</returns>
public async Task<string> GetExtensionBundlePath(HttpClient httpClient)
{
return await GetBundle(httpClient);
Expand Down
1 change: 1 addition & 0 deletions src/WebJobs.Script/ScriptConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public static class ScriptConstants
public const string DefaultMasterKeyName = "master";
public const string DefaultFunctionKeyName = "default";
public const string ColdStartEventName = "ColdStart";
public const string PlaceholderMissDueToBitnessEventName = "PlaceholderMissDueToBitness";

public const string FunctionsUserAgent = "AzureFunctionsRuntime";
public const string HttpScaleUserAgent = "HttpScaleManager";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,15 @@ private bool UsePlaceholderChannel(IRpcWorkerChannel channel)
return false;
}

// We support specialization of dotnet-isolated only on 64bit host process.
if (!_environment.Is64BitProcess)
{
Comment thread
kshyju marked this conversation as resolved.
Outdated
_logger.LogInformation(new EventId(421, ScriptConstants.PlaceholderMissDueToBitnessEventName),
"This app is configured as 32-bit and therefore does not leverage all performance optimizations. See https://aka.ms/azure-functions/dotnet/placeholders for more information.");

return false;
}

// Do not specialize if the placeholder is 6.0 but the site is 7.0 (for example).
var currentWorkerRuntimeVersion = _environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeVersionSettingName);
channel.WorkerProcess.Process.StartInfo.Environment.TryGetValue(RpcWorkerConstants.FunctionWorkerRuntimeVersionSettingName, out string placeholderWorkerRuntimeVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,24 @@ public async Task DotNetIsolated_PlaceholderMiss_EnvVar()
Assert.Contains("Shutting down placeholder worker. Worker is not compatible for runtime: dotnet-isolated", log);
}

[Fact]
public async Task DotNetIsolated_PlaceholderMiss_Not64Bit()
{
_environment.SetProcessBitness(is64Bitness: false);

// We only specialize when host process is 64 bit process.
await DotNetIsolatedPlaceholderMiss(() =>
{
_environment.SetEnvironmentVariable(EnvironmentSettingNames.AzureWebsiteUsePlaceholderDotNetIsolated, "1");
_environment.SetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeVersionSettingName, "6.0");
});

var log = _loggerProvider.GetLog();
Assert.Contains("UsePlaceholderDotNetIsolated: True", log);
Assert.Contains("This app is configured as 32-bit and therefore does not leverage all performance optimizations. See https://aka.ms/azure-functions/dotnet/placeholders for more information.", log);
Assert.Contains("Shutting down placeholder worker. Worker is not compatible for runtime: dotnet-isolated", log);
}

[Fact]
public async Task DotNetIsolated_PlaceholderMiss_DotNetVer()
{
Expand Down
16 changes: 15 additions & 1 deletion test/WebJobs.Script.Tests.Shared/TestEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,26 @@ namespace Microsoft.Azure.WebJobs.Script.Tests
public class TestEnvironment : IEnvironment
{
private readonly IDictionary<string, string> _variables;
private bool _is64BitProcess;

public TestEnvironment()
: this(new Dictionary<string, string>())
: this(new Dictionary<string, string>())
{
}

public TestEnvironment(IDictionary<string, string> variables)
: this(variables, is64BitProcess: true)
{
}

public TestEnvironment(IDictionary<string, string> variables, bool is64BitProcess)
{
_variables = variables ?? throw new ArgumentNullException(nameof(variables));
_is64BitProcess = is64BitProcess;
}

public bool Is64BitProcess => _is64BitProcess;

public void Clear()
{
_variables.Clear();
Expand Down Expand Up @@ -54,5 +63,10 @@ public static TestEnvironment FromEnvironmentVariables()

return new TestEnvironment(variables);
}

public void SetProcessBitness(bool is64Bitness)
{
_is64BitProcess = is64Bitness;
}
}
}