Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail fast if ExtendedSessionsEnabled is requested for a non-.NET worker. #2732

Merged
merged 14 commits into from
Oct 28, 2024
Merged
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
Loading