Skip to content

Commit

Permalink
Fail fast if ExtendedSessionsEnabled is requested for a non-.NET wo…
Browse files Browse the repository at this point in the history
…rker. (#2732)

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.

PR also includes:
* details why mssql test fails
* `docker build --pull` to ensure the dockerfile is consistently built from the latest base images, no matter where it's built.
  • Loading branch information
gukoff authored Oct 28, 2024
1 parent a7c6d69 commit 8470f3d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 18 deletions.
2 changes: 2 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### New Features

- 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

- Fix custom connection name not working when using IDurableClientFactory.CreateClient() - contributed by [@hctan](https://github.com/hctan)
Expand Down
2 changes: 1 addition & 1 deletion src/WebJobs.Extensions.DurableTask/DurableTaskExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 4 additions & 7 deletions src/WebJobs.Extensions.DurableTask/Options/DurableTaskOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -320,12 +320,9 @@ 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 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();
Expand Down
26 changes: 17 additions & 9 deletions test/Common/DurableTaskEndToEndTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5592,16 +5592,24 @@ 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();
}
InvalidOperationException exception =
await Assert.ThrowsAsync<InvalidOperationException>(async () =>
{
using (var host = TestHelpers.GetJobHostWithOptions(
this.loggerProvider,
durableTaskOptions,
nameResolver: nameResolver))
{
await host.StartAsync();
await host.StopAsync();
}
});

Assert.False(durableTaskOptions.ExtendedSessionsEnabled);
Assert.NotNull(exception);
Assert.StartsWith(
"Durable Functions with extendedSessionsEnabled set to 'true' is only supported when using",
exception.Message,
StringComparison.OrdinalIgnoreCase);
}

[Fact]
Expand Down
12 changes: 11 additions & 1 deletion test/SmokeTests/e2e-test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ $AzuriteVersion = "3.32.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
Expand All @@ -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
Expand Down

0 comments on commit 8470f3d

Please sign in to comment.