Skip to content

Commit 049c166

Browse files
4.7.1 hotfix (#8509)
* Fix cold start regression (#8505) * Removing service registration for profiles (#8502) * Update patch version Co-authored-by: Henry Hamid Safi <[email protected]>
1 parent 24dfa3d commit 049c166

15 files changed

+52
-64
lines changed

build/common.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<LangVersion>latest</LangVersion>
66
<MajorVersion>4</MajorVersion>
77
<MinorVersion>7</MinorVersion>
8-
<PatchVersion>0</PatchVersion>
8+
<PatchVersion>1</PatchVersion>
99
<BuildNumber Condition="'$(BuildNumber)' == '' ">0</BuildNumber>
1010
<PreviewVersion></PreviewVersion>
1111

src/WebJobs.Script/Host/DebugStateProvider.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ internal class DebugStateProvider : IDebugStateProvider, IDisposable
1414
internal const int DebugModeTimeoutMinutes = 15;
1515
internal const int DiagnosticModeTimeoutHours = 3;
1616
private readonly IOptionsMonitor<ScriptApplicationHostOptions> _scriptOptions;
17+
private readonly IEnvironment _environment;
1718
private IDisposable _debugModeEvent;
1819
private IDisposable _diagnosticModeEvent;
1920
private bool _disposed;
2021

21-
public DebugStateProvider(IOptionsMonitor<ScriptApplicationHostOptions> scriptOptions, IScriptEventManager eventManager)
22+
public DebugStateProvider(IEnvironment environment, IOptionsMonitor<ScriptApplicationHostOptions> scriptOptions, IScriptEventManager eventManager)
2223
{
24+
_environment = environment;
2325
_debugModeEvent = eventManager.OfType<DebugNotification>()
2426
.Subscribe(evt => LastDebugNotify = evt.NotificationTime);
2527
_diagnosticModeEvent = eventManager.OfType<DiagnosticNotification>()
@@ -41,8 +43,11 @@ public DebugStateProvider(IOptionsMonitor<ScriptApplicationHostOptions> scriptOp
4143

4244
private void InitializeLastNotificationTimes()
4345
{
44-
LastDebugNotify = GetLastWriteTime(ScriptConstants.DebugSentinelFileName);
45-
LastDiagnosticNotify = GetLastWriteTime(ScriptConstants.DiagnosticSentinelFileName);
46+
Utility.ExecuteAfterColdStartDelay(_environment, () =>
47+
{
48+
LastDebugNotify = GetLastWriteTime(ScriptConstants.DebugSentinelFileName);
49+
LastDiagnosticNotify = GetLastWriteTime(ScriptConstants.DiagnosticSentinelFileName);
50+
});
4651
}
4752

4853
private DateTime GetLastWriteTime(string fileName)

src/WebJobs.Script/ScriptHostBuilderExtensions.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,6 @@ public static IHostBuilder AddScriptHostCore(this IHostBuilder builder, ScriptAp
292292

293293
services.AddSingleton<IFileLoggingStatusManager, FileLoggingStatusManager>();
294294

295-
services.AddSingleton<IWorkerProfileManager, WorkerProfileManager>();
296-
297-
services.AddSingleton<IWorkerProfileConditionProvider, WorkerProfileConditionProvider>();
298-
299295
if (!applicationHostOptions.HasParentScope)
300296
{
301297
AddCommonServices(services);
@@ -339,8 +335,6 @@ public static void AddCommonServices(IServiceCollection services)
339335
services.TryAddSingleton<IWorkerConsoleLogSource, WorkerConsoleLogSource>();
340336
services.AddSingleton<IWorkerProcessFactory, DefaultWorkerProcessFactory>();
341337
services.AddSingleton<IRpcWorkerProcessFactory, RpcWorkerProcessFactory>();
342-
services.AddSingleton<IWorkerProfileManager, WorkerProfileManager>();
343-
services.AddSingleton<IWorkerProfileConditionProvider, WorkerProfileConditionProvider>();
344338
services.TryAddSingleton<IWebHostRpcWorkerChannelManager, WebHostRpcWorkerChannelManager>();
345339
services.TryAddSingleton<IDebugManager, DebugManager>();
346340
services.TryAddSingleton<IDebugStateProvider, DebugStateProvider>();

src/WebJobs.Script/Workers/Profiles/EnvironmentCondition.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public bool Evaluate()
5151
return false;
5252
}
5353

54-
_logger.LogDebug($"Evaluating EnvironmentCondition with value '{value}' and expression '{Expression}'");
54+
_logger.LogDebug($"Evaluating EnvironmentCondition with name: '{Name}', value: '{value}' and expression: '{Expression}'");
5555

5656
return _regex.IsMatch(value);
5757
}

src/WebJobs.Script/Workers/Profiles/HostPropertyCondition.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public bool Evaluate()
6868
return false;
6969
}
7070

71-
_logger.LogDebug($"Evaluating HostPropertyCondition with value: {value} and expression {Expression}");
71+
_logger.LogDebug($"Evaluating HostPropertyCondition with name: {Name}, value: {value} and expression {Expression}");
7272

7373
return _regex.IsMatch(value);
7474
}

src/WebJobs.Script/Workers/Profiles/WorkerProfileConditionProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ namespace Microsoft.Azure.WebJobs.Script.Workers
99
{
1010
internal sealed class WorkerProfileConditionProvider : IWorkerProfileConditionProvider
1111
{
12-
private readonly ILogger<WorkerProfileConditionProvider> _logger;
12+
private readonly ILogger _logger;
1313
private readonly IEnvironment _environment;
1414

15-
public WorkerProfileConditionProvider(ILogger<WorkerProfileConditionProvider> logger, IEnvironment environment)
15+
public WorkerProfileConditionProvider(ILogger logger, IEnvironment environment)
1616
{
1717
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
1818
_environment = environment ?? throw new ArgumentNullException(nameof(environment));

src/WebJobs.Script/Workers/Profiles/WorkerProfileManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal class WorkerProfileManager : IWorkerProfileManager
1919
private Dictionary<string, List<WorkerDescriptionProfile>> _profiles;
2020
private string _activeProfile;
2121

22-
public WorkerProfileManager(ILogger<WorkerProfileManager> logger, IEnumerable<IWorkerProfileConditionProvider> conditionProviders)
22+
public WorkerProfileManager(ILogger logger, IEnumerable<IWorkerProfileConditionProvider> conditionProviders)
2323
{
2424
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
2525
_conditionProviders = conditionProviders ?? throw new ArgumentNullException(nameof(conditionProviders));

src/WebJobs.Script/Workers/Rpc/Configuration/LanguageWorkerOptionsSetup.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ namespace Microsoft.Azure.WebJobs.Script.Workers.Rpc
1212
{
1313
internal class LanguageWorkerOptionsSetup : IConfigureOptions<LanguageWorkerOptions>
1414
{
15-
private readonly IWorkerProfileManager _profileConditionManager;
1615
private readonly IConfiguration _configuration;
1716
private readonly ILogger _logger;
1817
private readonly IEnvironment _environment;
@@ -21,15 +20,13 @@ internal class LanguageWorkerOptionsSetup : IConfigureOptions<LanguageWorkerOpti
2120
public LanguageWorkerOptionsSetup(IConfiguration configuration,
2221
ILoggerFactory loggerFactory,
2322
IEnvironment environment,
24-
IWorkerProfileManager profileConditionManager,
2523
IMetricsLogger metricsLogger)
2624
{
2725
if (loggerFactory is null)
2826
{
2927
throw new ArgumentNullException(nameof(loggerFactory));
3028
}
3129

32-
_profileConditionManager = profileConditionManager ?? throw new System.ArgumentNullException(nameof(profileConditionManager));
3330
_configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
3431
_environment = environment ?? throw new ArgumentNullException(nameof(environment));
3532
_metricsLogger = metricsLogger ?? throw new ArgumentNullException(nameof(metricsLogger));
@@ -47,9 +44,7 @@ public void Configure(LanguageWorkerOptions options)
4744
return;
4845
}
4946

50-
var configFactory = new RpcWorkerConfigFactory(_configuration, _logger, SystemRuntimeInformation.Instance,
51-
_profileConditionManager, _environment, _metricsLogger);
52-
47+
var configFactory = new RpcWorkerConfigFactory(_configuration, _logger, SystemRuntimeInformation.Instance, _environment, _metricsLogger);
5348
options.WorkerConfigs = configFactory.GetConfigs();
5449
}
5550
}

src/WebJobs.Script/Workers/Rpc/Configuration/RpcWorkerConfigFactory.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,12 @@ internal class RpcWorkerConfigFactory
3131
public RpcWorkerConfigFactory(IConfiguration config,
3232
ILogger logger,
3333
ISystemRuntimeInformation systemRuntimeInfo,
34-
IWorkerProfileManager profileManager,
3534
IEnvironment environment,
3635
IMetricsLogger metricsLogger)
3736
{
3837
_config = config ?? throw new ArgumentNullException(nameof(config));
3938
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
4039
_systemRuntimeInformation = systemRuntimeInfo ?? throw new ArgumentNullException(nameof(systemRuntimeInfo));
41-
_profileManager = profileManager ?? throw new ArgumentNullException(nameof(profileManager));
4240
_environment = environment ?? throw new ArgumentNullException(nameof(environment));
4341
_metricsLogger = metricsLogger;
4442
_workerRuntime = _environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeSettingName);
@@ -49,6 +47,11 @@ public RpcWorkerConfigFactory(IConfiguration config,
4947
{
5048
WorkersDirPath = workersDirectorySection.Value;
5149
}
50+
var conditionProviders = new List<IWorkerProfileConditionProvider>
51+
{
52+
new WorkerProfileConditionProvider(_logger, _environment)
53+
};
54+
_profileManager = new WorkerProfileManager(_logger, conditionProviders);
5255
}
5356

5457
public string WorkersDirPath { get; }

src/WebJobs.Script/Workers/Rpc/WebHostRpcWorkerChannelManager.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Threading.Tasks;
1010
using Microsoft.Azure.WebJobs.Script.Diagnostics;
1111
using Microsoft.Azure.WebJobs.Script.Eventing;
12+
using Microsoft.Azure.WebJobs.Script.Workers.Profiles;
1213
using Microsoft.Extensions.Configuration;
1314
using Microsoft.Extensions.Logging;
1415
using Microsoft.Extensions.Options;
@@ -39,8 +40,7 @@ public WebHostRpcWorkerChannelManager(IScriptEventManager eventManager,
3940
IRpcWorkerChannelFactory rpcWorkerChannelFactory,
4041
IOptionsMonitor<ScriptApplicationHostOptions> applicationHostOptions,
4142
IMetricsLogger metricsLogger, IOptionsMonitor<LanguageWorkerOptions> languageWorkerOptions,
42-
IConfiguration config,
43-
IWorkerProfileManager profileManager)
43+
IConfiguration config)
4444
{
4545
_environment = environment ?? throw new ArgumentNullException(nameof(environment));
4646
_eventManager = eventManager;
@@ -51,8 +51,11 @@ public WebHostRpcWorkerChannelManager(IScriptEventManager eventManager,
5151
_applicationHostOptions = applicationHostOptions;
5252
_lanuageworkerOptions = languageWorkerOptions;
5353
_config = config ?? throw new ArgumentNullException(nameof(config));
54-
_profileManager = profileManager ?? throw new ArgumentNullException(nameof(profileManager));
55-
54+
var conditionProviders = new List<IWorkerProfileConditionProvider>
55+
{
56+
new WorkerProfileConditionProvider(_logger, _environment)
57+
};
58+
_profileManager = new WorkerProfileManager(_logger, conditionProviders);
5659
_shutdownStandbyWorkerChannels = ScheduleShutdownStandbyChannels;
5760
_shutdownStandbyWorkerChannels = _shutdownStandbyWorkerChannels.Debounce(milliseconds: 5000);
5861
}

0 commit comments

Comments
 (0)