Skip to content

Commit 4288445

Browse files
authored
Platform release channel bundles resolution fix and additional logging (#10921)
1 parent cbd18f4 commit 4288445

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

release_notes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
- Allow sync trigger to happen in managed environment when `AzureWebJobsStorage` is not set (#10767)
1010
- Fixing default DateTime bug with TimeZones in TimerTrigger (#10906)
1111
- Adjusting the logic to determine the warmup call in placeholder simulation mode to align with the production flow (#10918)
12-
- Fixing invalid DateTimes in status blobs when invoking via portal (#10916)
12+
- Fixing invalid DateTimes in status blobs when invoking via portal (#10916)
13+
- Bug fix for platform release channel bundles resolution casing issue and additional logging (#10921)

src/WebJobs.Script/ExtensionBundle/ExtensionBundleManager.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Linq;
99
using System.Net.Http;
1010
using System.Threading.Tasks;
11-
using Grpc.Net.Client.Balancer;
1211
using Microsoft.Azure.WebJobs.Script.Config;
1312
using Microsoft.Azure.WebJobs.Script.Configuration;
1413
using Microsoft.Azure.WebJobs.Script.Diagnostics.Extensions;
@@ -294,7 +293,7 @@ internal string FindBestVersionMatch(VersionRange versionRange, IEnumerable<stri
294293
return matchingVersion?.ToString();
295294
}
296295

297-
private NuGetVersion ResolvePlatformReleaseChannelVersion(IList<NuGetVersion> orderedByDescBundles) => _platformReleaseChannel switch
296+
private NuGetVersion ResolvePlatformReleaseChannelVersion(IList<NuGetVersion> orderedByDescBundles) => _platformReleaseChannel.ToUpper() switch
298297
{
299298
ScriptConstants.StandardPlatformChannelNameUpper or ScriptConstants.ExtendedPlatformChannelNameUpper => GetStandardOrExtendedBundleVersion(orderedByDescBundles),
300299
ScriptConstants.LatestPlatformChannelNameUpper or "" => GetLatestBundleVersion(orderedByDescBundles),
@@ -306,27 +305,36 @@ internal string FindBestVersionMatch(VersionRange versionRange, IEnumerable<stri
306305
// However, Functions and Rapid Update should treat Standard and Extended the same, resolving to n-1.
307306
private NuGetVersion GetStandardOrExtendedBundleVersion(IList<NuGetVersion> orderedByDescBundlesList)
308307
{
308+
var latest = orderedByDescBundlesList.FirstOrDefault();
309+
309310
if (orderedByDescBundlesList.Count > 1)
310311
{
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+
311315
// 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].
312-
return orderedByDescBundlesList[1];
316+
return previous;
313317
}
314318

315319
// keep the latest version, log a notice
316-
var latest = orderedByDescBundlesList.FirstOrDefault();
317-
_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);
318321
return latest;
319322
}
320323

321-
private static NuGetVersion GetLatestBundleVersion(IList<NuGetVersion> orderedByDescBundlesList)
324+
private NuGetVersion GetLatestBundleVersion(IList<NuGetVersion> orderedByDescBundlesList)
322325
{
323-
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;
324332
}
325333

326334
private NuGetVersion HandleUnknownPlatformReleaseChannelName(IList<NuGetVersion> orderedByDescBundlesList)
327335
{
328336
var latest = GetLatestBundleVersion(orderedByDescBundlesList);
329-
_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);
330338
return latest;
331339
}
332340

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)