Skip to content

Commit 4b00fcb

Browse files
authored
Platform release channel bundles resolution fix and additional logging (#10922)
1 parent 939385d commit 4b00fcb

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

release_notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
- Update PowerShell worker to 4.0.4175 (sets defaultRuntimeVersion to 7.4 in worker.config.json)
99
- Fixing default DateTime bug with TimeZones in TimerTrigger (#10906)
1010
- Add support for the release channel setting `WEBSITE_PlatformReleaseChannel` and use this value in extension bundles resolution.
11+
- Bug fix for platform release channel bundles resolution casing issue and additional logging (#10921)

src/WebJobs.Script/ExtensionBundle/ExtensionBundleManager.cs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ internal string FindBestVersionMatch(VersionRange versionRange, IEnumerable<stri
293293
return matchingVersion?.ToString();
294294
}
295295

296-
private NuGetVersion ResolvePlatformReleaseChannelVersion(IList<NuGetVersion> orderedByDescBundles) => _platformReleaseChannel switch
296+
private NuGetVersion ResolvePlatformReleaseChannelVersion(IList<NuGetVersion> orderedByDescBundles) => _platformReleaseChannel.ToUpper() switch
297297
{
298298
ScriptConstants.StandardPlatformChannelNameUpper or ScriptConstants.ExtendedPlatformChannelNameUpper => GetStandardOrExtendedBundleVersion(orderedByDescBundles),
299299
ScriptConstants.LatestPlatformChannelNameUpper or "" => GetLatestBundleVersion(orderedByDescBundles),
@@ -305,27 +305,36 @@ internal string FindBestVersionMatch(VersionRange versionRange, IEnumerable<stri
305305
// However, Functions and Rapid Update should treat Standard and Extended the same, resolving to n-1.
306306
private NuGetVersion GetStandardOrExtendedBundleVersion(IList<NuGetVersion> orderedByDescBundlesList)
307307
{
308+
var latest = orderedByDescBundlesList.FirstOrDefault();
309+
308310
if (orderedByDescBundlesList.Count > 1)
309311
{
312+
var previous = orderedByDescBundlesList[1];
313+
_logger.LogInformation("Applying platform release channel configuration {platformReleaseChannelName}. Previous bundle version {previous} will be used instead of latest version {latest}.", _platformReleaseChannel, previous, latest);
314+
310315
// These channels should resolve to the version prior to latest. This list is in descending order, which makes latest [0], and prior-to-latest [1].
311-
return orderedByDescBundlesList[1];
316+
return previous;
312317
}
313318

314319
// keep the latest version, log a notice
315-
var latest = orderedByDescBundlesList.FirstOrDefault();
316-
_logger.LogInformation("Unable to apply platform release channel configuration {platformReleaseChannelName}. Only one matching bundle version is available. {latestBundleVersion} will be used", _platformReleaseChannel, latest);
320+
_logger.LogWarning("Unable to apply platform release channel configuration {platformReleaseChannelName}. Only one matching bundle version is available. {latestBundleVersion} will be used", _platformReleaseChannel, latest);
317321
return latest;
318322
}
319323

320-
private static NuGetVersion GetLatestBundleVersion(IList<NuGetVersion> orderedByDescBundlesList)
324+
private NuGetVersion GetLatestBundleVersion(IList<NuGetVersion> orderedByDescBundlesList)
321325
{
322-
return orderedByDescBundlesList.FirstOrDefault();
326+
var latest = orderedByDescBundlesList.FirstOrDefault();
327+
if (string.Equals(_platformReleaseChannel.ToUpper(), ScriptConstants.LatestPlatformChannelNameUpper))
328+
{
329+
_logger.LogInformation("Applying platform release channel configuration {platformReleaseChannelName}. Bundle version {latest} will be used", _platformReleaseChannel, latest);
330+
}
331+
return latest;
323332
}
324333

325334
private NuGetVersion HandleUnknownPlatformReleaseChannelName(IList<NuGetVersion> orderedByDescBundlesList)
326335
{
327336
var latest = GetLatestBundleVersion(orderedByDescBundlesList);
328-
_logger.LogInformation("Unknown platform release channel name {platformReleaseChannelName}. The latest bundle version, {latestBundleVersion}, will be used.", _platformReleaseChannel, latest);
337+
_logger.LogWarning("Unknown platform release channel name {platformReleaseChannelName}. The latest bundle version, {latestBundleVersion}, will be used.", _platformReleaseChannel, latest);
329338
return latest;
330339
}
331340

test/WebJobs.Script.Tests/ExtensionBundle/ExtensionBundleManagerTests.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,11 @@ public void LimitMaxVersion(string versionRange, string hostConfigVersion, strin
418418
[InlineData(ScriptConstants.StandardPlatformChannelNameUpper, "[4.*, 5.0.0)", "4.1.0", "4.1.0")]
419419
[InlineData(ScriptConstants.ExtendedPlatformChannelNameUpper, "[4.*, 5.0.0)", "4.1.0", "4.1.0")]
420420
[InlineData(ScriptConstants.LatestPlatformChannelNameUpper, "[4.*, 5.0.0)", null, "4.3.0")]
421+
[InlineData("latest", "[4.*, 5.0.0)", null, "4.3.0")]
421422
[InlineData(ScriptConstants.StandardPlatformChannelNameUpper, "[4.*, 5.0.0)", null, "4.2.0")]
423+
[InlineData("standard", "[4.*, 5.0.0)", null, "4.2.0")]
422424
[InlineData(ScriptConstants.ExtendedPlatformChannelNameUpper, "[4.*, 5.0.0)", null, "4.2.0")]
425+
[InlineData("extended", "[4.*, 5.0.0)", null, "4.2.0")]
423426
public void WhenPlatformReleaseChannelSet_ExpectedVersionChosen(string platformReleaseChannelName, string versionRange, string hostConfigMaxVersion, string expectedVersion)
424427
{
425428
var range = VersionRange.Parse(versionRange);
@@ -462,7 +465,7 @@ public void StandardExtendedReleaseChannel_OneBundleVersionOnDisk_Handled(string
462465
var expected = "4.20.0";
463466

464467
var loggedString = $"Unable to apply platform release channel configuration {platformReleaseChannelName}. Only one matching bundle version is available. {expected} will be used";
465-
var mockLogger = GetVerifiableMockLogger(loggedString);
468+
var mockLogger = GetVerifiableMockLogger(loggedString, LogLevel.Warning);
466469
var mockLoggerFactory = new Mock<ILoggerFactory>();
467470
mockLoggerFactory.Setup(f => f.CreateLogger(It.IsAny<string>())).Returns(() => mockLogger.Object);
468471

@@ -485,7 +488,7 @@ public void UnknownReleaseChannel_ExpectedVersionChosen()
485488

486489
var incorrectChannelName = "someIncorrectReleaseChannelName";
487490
var loggedString = $"Unknown platform release channel name {incorrectChannelName}. The latest bundle version, {expected}, will be used.";
488-
var mockLogger = GetVerifiableMockLogger(loggedString);
491+
var mockLogger = GetVerifiableMockLogger(loggedString, LogLevel.Warning);
489492
var mockLoggerFactory = new Mock<ILoggerFactory>();
490493
mockLoggerFactory.Setup(f => f.CreateLogger(It.IsAny<string>())).Returns(() => mockLogger.Object);
491494

@@ -573,12 +576,12 @@ private IList<string> GetLargeVersionsList()
573576
{ "3.7.0", "3.10.0", "3.11.0", "3.15.0", "3.14.0", "2.16.0", "3.13.0", "3.12.0", "3.9.1", "2.12.1", "2.18.0", "3.16.0", "2.19.0", "3.17.0", "4.0.2", "2.20.0", "3.18.0", "4.1.0", "4.2.0", "2.21.0", "3.19.0", "3.19.2", "4.3.0", "3.20.0" };
574577
}
575578

576-
private Mock<ILogger> GetVerifiableMockLogger(string stringToVerify)
579+
private Mock<ILogger> GetVerifiableMockLogger(string stringToVerify, LogLevel logLevel)
577580
{
578581
var mockLogger = new Mock<ILogger>();
579582
mockLogger
580583
.Setup(x => x.Log(
581-
LogLevel.Information,
584+
logLevel,
582585
It.IsAny<EventId>(),
583586
It.Is<It.IsAnyType>((v, t) => v.ToString().Contains(stringToVerify)),
584587
It.IsAny<Exception>(),

0 commit comments

Comments
 (0)