From a15efe61ab46989f12e20adca13d32d5488f7ae0 Mon Sep 17 00:00:00 2001 From: Tony Choi Date: Wed, 13 Aug 2025 11:35:02 -0700 Subject: [PATCH 1/3] [LinuxConsumption] Mark Container Unhealthy During Failed Specialization --- .../Management/AtlasInstanceManager.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/WebJobs.Script.WebHost/Management/AtlasInstanceManager.cs b/src/WebJobs.Script.WebHost/Management/AtlasInstanceManager.cs index a4cf1948dc..5ea70beb6e 100644 --- a/src/WebJobs.Script.WebHost/Management/AtlasInstanceManager.cs +++ b/src/WebJobs.Script.WebHost/Management/AtlasInstanceManager.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. using System; @@ -301,13 +301,22 @@ await _runFromPackageHandler.ApplyRunFromPackageContext(pkgContext, options.Scri } else { + bool succeeded = true; if (pkgContext.IsRunFromPackage(options, _logger)) { - await _runFromPackageHandler.ApplyRunFromPackageContext(pkgContext, options.ScriptPath, false); + succeeded = await _runFromPackageHandler.ApplyRunFromPackageContext(pkgContext, options.ScriptPath, false); } else if (assignmentContext.IsAzureFilesContentShareConfigured(_logger)) { - await _runFromPackageHandler.MountAzureFileShare(assignmentContext); + succeeded = await _runFromPackageHandler.MountAzureFileShare(assignmentContext); + } + + if (!succeeded) + { + await _meshServiceClient.NotifyHealthEvent(ContainerHealthEventType.Fatal, this.GetType(), + "Failed to apply Run-From-Package context or mount Azure File Share"); + + throw new Exception("Failed to apply Run-From-Package context or mount Azure File Share"); } } From 5e647a1464319f59e0820d9b71f9c45fe20a6623 Mon Sep 17 00:00:00 2001 From: Tony Choi Date: Wed, 13 Aug 2025 11:49:52 -0700 Subject: [PATCH 2/3] Updating release note --- release_notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_notes.md b/release_notes.md index 7f2d3d806a..912ee06406 100644 --- a/release_notes.md +++ b/release_notes.md @@ -6,4 +6,4 @@ - Add JitTrace Files for v4.1042 - Updating OTel related nuget packages (#11216) - Moving to version 1.5.7 of Microsoft.Azure.AppService.Middleware.Functions (https://github.com/Azure/azure-functions-host/pull/11231) - +- Mark Failed Container Specialization as Fatal (https://github.com/Azure/azure-functions-host/pull/11250) From 041f502db58abe4dc863322534e087fe43a76e98 Mon Sep 17 00:00:00 2001 From: Tony Choi Date: Thu, 14 Aug 2025 14:02:44 -0700 Subject: [PATCH 3/3] moving the failure --- .../Management/AtlasInstanceManager.cs | 18 +++++++----------- .../Management/InstanceManagerTests.cs | 6 +++++- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/WebJobs.Script.WebHost/Management/AtlasInstanceManager.cs b/src/WebJobs.Script.WebHost/Management/AtlasInstanceManager.cs index 5ea70beb6e..720eec0f84 100644 --- a/src/WebJobs.Script.WebHost/Management/AtlasInstanceManager.cs +++ b/src/WebJobs.Script.WebHost/Management/AtlasInstanceManager.cs @@ -276,6 +276,11 @@ await _runFromPackageHandler.ApplyRunFromPackageContext(pkgContext, options.Scri _logger.LogWarning($"Failed to {nameof(_runFromPackageHandler.ApplyRunFromPackageContext)}. Attempting to use local disk instead"); await _runFromPackageHandler.ApplyRunFromPackageContext(pkgContext, options.ScriptPath, false); } + else if (!blobContextApplied && !azureFilesMounted) + { + await _meshServiceClient.NotifyHealthEvent(ContainerHealthEventType.Fatal, this.GetType(), + $"Failed to mount Azure File Share and failed to {nameof(_runFromPackageHandler.ApplyRunFromPackageContext)}"); + } } else if (pkgContext.IsRunFromLocalPackage()) { @@ -301,22 +306,13 @@ await _runFromPackageHandler.ApplyRunFromPackageContext(pkgContext, options.Scri } else { - bool succeeded = true; if (pkgContext.IsRunFromPackage(options, _logger)) { - succeeded = await _runFromPackageHandler.ApplyRunFromPackageContext(pkgContext, options.ScriptPath, false); + await _runFromPackageHandler.ApplyRunFromPackageContext(pkgContext, options.ScriptPath, false); } else if (assignmentContext.IsAzureFilesContentShareConfigured(_logger)) { - succeeded = await _runFromPackageHandler.MountAzureFileShare(assignmentContext); - } - - if (!succeeded) - { - await _meshServiceClient.NotifyHealthEvent(ContainerHealthEventType.Fatal, this.GetType(), - "Failed to apply Run-From-Package context or mount Azure File Share"); - - throw new Exception("Failed to apply Run-From-Package context or mount Azure File Share"); + await _runFromPackageHandler.MountAzureFileShare(assignmentContext); } } diff --git a/test/WebJobs.Script.Tests.Integration/Management/InstanceManagerTests.cs b/test/WebJobs.Script.Tests.Integration/Management/InstanceManagerTests.cs index 1fdae1cdcf..c327800496 100644 --- a/test/WebJobs.Script.Tests.Integration/Management/InstanceManagerTests.cs +++ b/test/WebJobs.Script.Tests.Integration/Management/InstanceManagerTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. using System; @@ -1190,6 +1190,10 @@ public async Task Falls_Back_To_Local_Disk_If_Azure_Files_Unavailable_Only_If_Az .Setup(r => r.ApplyRunFromPackageContext(It.IsAny(), It.IsAny(), false, false)).ReturnsAsync(false); // return false to trigger failure + // setup notifyhealth method + _meshServiceClientMock.Setup(m => m.NotifyHealthEvent(ContainerHealthEventType.Fatal, + It.IsAny(), It.IsAny())).Returns(Task.CompletedTask); + // There will be no 2nd attempt since azure files mounting failed. var optionsFactory = new TestOptionsFactory(new ScriptApplicationHostOptions() { ScriptPath = scriptPath });