From 7369062b5b27cfb40edc520044502aa10149ff0b Mon Sep 17 00:00:00 2001 From: Konstantin Gukov Date: Fri, 26 Jan 2024 16:16:29 +0100 Subject: [PATCH 01/10] Fail fast if `extendedSessions` is requested for a non-.NET worker. While the code does emit the warning and overwrites the option value, this is too late. The frameworks reads the "old" option value before the options are validated and actually runs as if the extended sessions are on. This leads to the hard-to-troubleshoot problems, e.g. the python worker never re-triggers the orchestration and never completes them. --- .../Options/DurableTaskOptions.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/WebJobs.Extensions.DurableTask/Options/DurableTaskOptions.cs b/src/WebJobs.Extensions.DurableTask/Options/DurableTaskOptions.cs index bc555386f..94aff3d80 100644 --- a/src/WebJobs.Extensions.DurableTask/Options/DurableTaskOptions.cs +++ b/src/WebJobs.Extensions.DurableTask/Options/DurableTaskOptions.cs @@ -320,12 +320,10 @@ internal void Validate(INameResolver environmentVariableResolver, EndToEndTraceH runtimeLanguage != null && // If we don't know from the environment variable, don't assume customer isn't .NET !string.Equals(runtimeLanguage, "dotnet", StringComparison.OrdinalIgnoreCase)) { - traceHelper.ExtensionWarningEvent( - hubName: this.HubName, - functionName: string.Empty, - instanceId: string.Empty, - message: "Durable Functions does not work with extendedSessions = true for non-.NET languages. This value is being set to false instead. See https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-perf-and-scale#extended-sessions for more details."); - this.ExtendedSessionsEnabled = false; + throw new InvalidOperationException( + "Durable Functions does not work with ExtendedSessionsEnabled = true for non-.NET languages. " + + "This value is being set to false instead. " + + "See https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-perf-and-scale#extended-sessions for more details."); } this.Notifications.Validate(); From 9a52474b907984ca7632d290b0aef17c24f5db3e Mon Sep 17 00:00:00 2001 From: Konstantin Gukov Date: Fri, 26 Jan 2024 16:52:17 +0100 Subject: [PATCH 02/10] Remove unused trace helper --- src/WebJobs.Extensions.DurableTask/DurableTaskExtension.cs | 2 +- .../Options/DurableTaskOptions.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/WebJobs.Extensions.DurableTask/DurableTaskExtension.cs b/src/WebJobs.Extensions.DurableTask/DurableTaskExtension.cs index 3ae312bef..0ccdadc99 100644 --- a/src/WebJobs.Extensions.DurableTask/DurableTaskExtension.cs +++ b/src/WebJobs.Extensions.DurableTask/DurableTaskExtension.cs @@ -359,7 +359,7 @@ void IExtensionConfigProvider.Initialize(ExtensionConfigContext context) } // Throw if any of the configured options are invalid - this.Options.Validate(this.nameResolver, this.TraceHelper); + this.Options.Validate(this.nameResolver); #pragma warning disable CS0618 // Type or member is obsolete diff --git a/src/WebJobs.Extensions.DurableTask/Options/DurableTaskOptions.cs b/src/WebJobs.Extensions.DurableTask/Options/DurableTaskOptions.cs index 94aff3d80..a6d8e50e1 100644 --- a/src/WebJobs.Extensions.DurableTask/Options/DurableTaskOptions.cs +++ b/src/WebJobs.Extensions.DurableTask/Options/DurableTaskOptions.cs @@ -302,7 +302,7 @@ internal void TraceConfiguration(EndToEndTraceHelper traceHelper, JObject storag traceHelper.TraceConfiguration(this.HubName, configurationJson.ToString(Formatting.None)); } - internal void Validate(INameResolver environmentVariableResolver, EndToEndTraceHelper traceHelper) + internal void Validate(INameResolver environmentVariableResolver) { if (string.IsNullOrEmpty(this.HubName)) { From 10c6e0e94a0368678cf58140a3370c039d6b3d63 Mon Sep 17 00:00:00 2001 From: Konstantin Gukov Date: Sun, 28 Jan 2024 20:58:10 +0100 Subject: [PATCH 03/10] Correct exception message --- .../Options/DurableTaskOptions.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/WebJobs.Extensions.DurableTask/Options/DurableTaskOptions.cs b/src/WebJobs.Extensions.DurableTask/Options/DurableTaskOptions.cs index a6d8e50e1..c7322044e 100644 --- a/src/WebJobs.Extensions.DurableTask/Options/DurableTaskOptions.cs +++ b/src/WebJobs.Extensions.DurableTask/Options/DurableTaskOptions.cs @@ -321,9 +321,8 @@ internal void Validate(INameResolver environmentVariableResolver) !string.Equals(runtimeLanguage, "dotnet", StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException( - "Durable Functions does not work with ExtendedSessionsEnabled = true for non-.NET languages. " + - "This value is being set to false instead. " + - "See https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-perf-and-scale#extended-sessions for more details."); + "Durable Functions with extendedSessionsEnabled set to 'true' is only supported when using the in-process .NET worker. Please remove the setting or change it to 'false'." + + "See https://docs.microsoft.com/azure/azure-functions/durable/durable-functions-perf-and-scale#extended-sessions for more details."); } this.Notifications.Validate(); From 58cf877a43d36e88524a77585444ba448cd3beff Mon Sep 17 00:00:00 2001 From: Konstantin Gukov Date: Thu, 25 Jul 2024 14:00:17 +0200 Subject: [PATCH 04/10] fix text --- test/Common/DurableTaskEndToEndTests.cs | 28 +++++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/test/Common/DurableTaskEndToEndTests.cs b/test/Common/DurableTaskEndToEndTests.cs index 1044eddab..4613990bf 100644 --- a/test/Common/DurableTaskEndToEndTests.cs +++ b/test/Common/DurableTaskEndToEndTests.cs @@ -5577,16 +5577,26 @@ public async Task ExtendedSessions_OutOfProc_SetToFalse() { "FUNCTIONS_WORKER_RUNTIME", "node" }, }); - using (var host = TestHelpers.GetJobHostWithOptions( - this.loggerProvider, - durableTaskOptions, - nameResolver: nameResolver)) - { - await host.StartAsync(); - await host.StopAsync(); - } - Assert.False(durableTaskOptions.ExtendedSessionsEnabled); + InvalidOperationException exception = + await Assert.ThrowsAsync(async () => + { + using (var host = TestHelpers.GetJobHostWithOptions( + this.loggerProvider, + durableTaskOptions, + nameResolver: nameResolver)) + { + await host.StartAsync(); + await host.StopAsync(); + } + }); + + Assert.NotNull(exception); + Assert.StartsWith( + "Durable Functions with extendedSessionsEnabled set to 'true' is only supported when using", + exception.Message, + StringComparison.OrdinalIgnoreCase + ) } [Fact] From 502cb86bd99004be6df3d28a7266f38d4c98d7fc Mon Sep 17 00:00:00 2001 From: Konstantin Gukov Date: Thu, 25 Jul 2024 14:25:29 +0200 Subject: [PATCH 05/10] semicolon --- test/Common/DurableTaskEndToEndTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Common/DurableTaskEndToEndTests.cs b/test/Common/DurableTaskEndToEndTests.cs index 1ad4f2ff7..7a779ecbe 100644 --- a/test/Common/DurableTaskEndToEndTests.cs +++ b/test/Common/DurableTaskEndToEndTests.cs @@ -5611,7 +5611,7 @@ await Assert.ThrowsAsync(async () => "Durable Functions with extendedSessionsEnabled set to 'true' is only supported when using", exception.Message, StringComparison.OrdinalIgnoreCase - ) + ); } [Fact] From 9f00ae5ec5965345411c53d709e3b556768287e9 Mon Sep 17 00:00:00 2001 From: Konstantin Gukov Date: Mon, 5 Aug 2024 14:08:55 +0200 Subject: [PATCH 06/10] linter --- test/Common/DurableTaskEndToEndTests.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/Common/DurableTaskEndToEndTests.cs b/test/Common/DurableTaskEndToEndTests.cs index 7a779ecbe..0ba61d7f3 100644 --- a/test/Common/DurableTaskEndToEndTests.cs +++ b/test/Common/DurableTaskEndToEndTests.cs @@ -5592,7 +5592,6 @@ public async Task ExtendedSessions_OutOfProc_SetToFalse() { "FUNCTIONS_WORKER_RUNTIME", "node" }, }); - InvalidOperationException exception = await Assert.ThrowsAsync(async () => { @@ -5610,8 +5609,7 @@ await Assert.ThrowsAsync(async () => Assert.StartsWith( "Durable Functions with extendedSessionsEnabled set to 'true' is only supported when using", exception.Message, - StringComparison.OrdinalIgnoreCase - ); + StringComparison.OrdinalIgnoreCase); } [Fact] From 12035d48a4386a469b7d7b51a066c2fc4ae4f273 Mon Sep 17 00:00:00 2001 From: Konstantin Gukov Date: Fri, 9 Aug 2024 12:17:33 +0200 Subject: [PATCH 07/10] attempt to rebuild with the latest images --- test/SmokeTests/e2e-test.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/SmokeTests/e2e-test.ps1 b/test/SmokeTests/e2e-test.ps1 index e7a7aa8c1..b77f9a143 100644 --- a/test/SmokeTests/e2e-test.ps1 +++ b/test/SmokeTests/e2e-test.ps1 @@ -31,7 +31,7 @@ $AzuriteVersion = "3.26.0" if ($NoSetup -eq $false) { # Build the docker image first, since that's the most critical step Write-Host "Building sample app Docker container from '$DockerfilePath'..." -ForegroundColor Yellow - docker build -f $DockerfilePath -t $ImageName --progress plain $PSScriptRoot/../../ + docker build --pull --no-cache -f $DockerfilePath -t $ImageName --progress plain $PSScriptRoot/../../ Exit-OnError # Next, download and start the Azurite emulator Docker image From cd259ab721a7dc2b154271adc1e8f523157f110c Mon Sep 17 00:00:00 2001 From: Konstantin Gukov Date: Fri, 9 Aug 2024 12:50:05 +0200 Subject: [PATCH 08/10] detail why mssql test fails --- test/SmokeTests/e2e-test.ps1 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/SmokeTests/e2e-test.ps1 b/test/SmokeTests/e2e-test.ps1 index b77f9a143..674b89974 100644 --- a/test/SmokeTests/e2e-test.ps1 +++ b/test/SmokeTests/e2e-test.ps1 @@ -31,7 +31,7 @@ $AzuriteVersion = "3.26.0" if ($NoSetup -eq $false) { # Build the docker image first, since that's the most critical step Write-Host "Building sample app Docker container from '$DockerfilePath'..." -ForegroundColor Yellow - docker build --pull --no-cache -f $DockerfilePath -t $ImageName --progress plain $PSScriptRoot/../../ + docker build -f $DockerfilePath -t $ImageName --progress plain $PSScriptRoot/../../ Exit-OnError # Next, download and start the Azurite emulator Docker image @@ -58,6 +58,16 @@ if ($NoSetup -eq $false) { Start-Sleep -Seconds 30 # Adjust the sleep duration based on your SQL Server container startup time Exit-OnError + Write-Host "Checking if SQL Server is still running..." -ForegroundColor Yellow + $sqlServerStatus = docker inspect -f '{{.State.Status}}' mssql-server + Exit-OnError + + if ($sqlServerStatus -ne "running") { + Write-Host "Unexpected SQL Server status: $sqlServerStatus" -ForegroundColor Yellow + docker logs mssql-server + exit 1; + } + # Get SQL Server IP Address - used to create SQLDB_Connection Write-Host "Getting IP Address..." -ForegroundColor Yellow $serverIpAddress = docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mssql-server From e78c2ebde83c051f55434ffac0b3ec5a13f40382 Mon Sep 17 00:00:00 2001 From: Konstantin Gukov Date: Fri, 9 Aug 2024 14:31:17 +0200 Subject: [PATCH 09/10] `docker build --pull` to ensure the dockerfile is consistently built from the latest base images, no matter where it's built. --- test/SmokeTests/e2e-test.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/SmokeTests/e2e-test.ps1 b/test/SmokeTests/e2e-test.ps1 index 674b89974..725988d4c 100644 --- a/test/SmokeTests/e2e-test.ps1 +++ b/test/SmokeTests/e2e-test.ps1 @@ -31,7 +31,7 @@ $AzuriteVersion = "3.26.0" if ($NoSetup -eq $false) { # Build the docker image first, since that's the most critical step Write-Host "Building sample app Docker container from '$DockerfilePath'..." -ForegroundColor Yellow - docker build -f $DockerfilePath -t $ImageName --progress plain $PSScriptRoot/../../ + docker build --pull -f $DockerfilePath -t $ImageName --progress plain $PSScriptRoot/../../ Exit-OnError # Next, download and start the Azurite emulator Docker image From 87b283ad70e2f9e957b9831cfd0b2d0fa46214b0 Mon Sep 17 00:00:00 2001 From: Konstantin Gukov Date: Fri, 9 Aug 2024 15:05:12 +0200 Subject: [PATCH 10/10] Release notes --- release_notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/release_notes.md b/release_notes.md index ad44bb9b3..11119ac0e 100644 --- a/release_notes.md +++ b/release_notes.md @@ -5,6 +5,7 @@ ### New Features - Fix regression on `TerminateInstanceAsync` API causing invocations to fail with "unimplemented" exceptions (https://github.com/Azure/azure-functions-durable-extension/pull/2829). +- Fail fast if extendedSessionsEnabled set to 'true' for the worker type that doesn't support extended sessions (https://github.com/Azure/azure-functions-durable-extension/pull/2732). ### Bug Fixes