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

WaitFor integration with Health Check Service #5515

Merged
merged 29 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
50808ed
WIP.
mitchdenny Sep 1, 2024
f7d199b
WIP
mitchdenny Sep 2, 2024
231e93f
WIP
mitchdenny Sep 2, 2024
5cc25e1
Moved over to using RNS to detecting health.
mitchdenny Sep 2, 2024
50252a9
Connection strings without config.
mitchdenny Sep 2, 2024
d9189b0
Add playground for WaitFor.
mitchdenny Sep 3, 2024
65d4eed
Tidy up capture of connection string in Redis.
mitchdenny Sep 3, 2024
8b46ab0
Progress on WaitFor on Azure resource.
mitchdenny Sep 3, 2024
f98ccb9
Make HealthStatus null by default.
mitchdenny Sep 3, 2024
ee4e611
Remove WaitFor in testshop.
mitchdenny Sep 4, 2024
bd3b710
Put project based dashboard back in.
mitchdenny Sep 4, 2024
e8d8a42
Added ConnectionStringAvailableEvent and fire from within AppExecutor…
mitchdenny Sep 4, 2024
a801683
Forgot Redis extensions.
mitchdenny Sep 4, 2024
f115faf
Fix up manifest.
mitchdenny Sep 4, 2024
d57f7a3
Health check name.
mitchdenny Sep 4, 2024
4c93885
Keep track of resources and surrogate resources to avoid searches.
mitchdenny Sep 5, 2024
bff081e
Get child resources updating correcting in Azure provisioner.
mitchdenny Sep 5, 2024
dc6675e
Clean-up playgrounds.
mitchdenny Sep 5, 2024
4a639e6
PR feedback.
mitchdenny Sep 5, 2024
4d95831
WaitFor works on Postgres database resource.
mitchdenny Sep 6, 2024
7973a2c
Add WithHealthCheck.
mitchdenny Sep 6, 2024
86b5f6a
Update RedisBuilderExtensions.cs
mitchdenny Sep 6, 2024
e0aceae
Remove whitespace change.
mitchdenny Sep 6, 2024
007c2b6
Merge branch 'mitchdenny/healthcheckintegration' of https://github.co…
mitchdenny Sep 6, 2024
0587773
Throw when connection string not available.
mitchdenny Sep 6, 2024
6652a18
Functional tests.
mitchdenny Sep 6, 2024
c55f588
Ignore health check service errors in app host logs for now.
mitchdenny Sep 6, 2024
1f83066
Add some XML doc comments.
mitchdenny Sep 6, 2024
572bcc9
Add remarks to APIs.
mitchdenny Sep 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Aspire.sln
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.Hosting.Dapr.Tests",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.Hosting.AWS.Tests", "tests\Aspire.Hosting.AWS.Tests\Aspire.Hosting.AWS.Tests.csproj", "{6F71BC73-B703-4E64-98E0-801781302E7A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "waitfor", "waitfor", "{3FF3F00C-95C0-46FC-B2BE-A3920C71E393}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WaitForSandbox.AppHost", "playground\waitfor\WaitForSandbox.AppHost\WaitForSandbox.AppHost.csproj", "{415E011A-1C56-41A1-BAEB-CA5D5CED1A57}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WaitForSandbox.ApiService", "playground\waitfor\WaitForSandbox.ApiService\WaitForSandbox.ApiService.csproj", "{C554C480-3DA7-4D62-A09A-3F3F743D7A66}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WaitForSandbox.DbSetup", "playground\waitfor\WaitForSandbox.DbSetup\WaitForSandbox.DbSetup.csproj", "{37BC5B4A-3F96-4BB0-92E6-81666F4324E4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WaitForSandbox.Common", "playground\waitfor\WaitForSandbox.Common\WaitForSandbox.Common.csproj", "{F0C976EF-EE26-4EA9-B324-0CD21DCEA140}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1537,6 +1547,22 @@ Global
{6F71BC73-B703-4E64-98E0-801781302E7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6F71BC73-B703-4E64-98E0-801781302E7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6F71BC73-B703-4E64-98E0-801781302E7A}.Release|Any CPU.Build.0 = Release|Any CPU
{415E011A-1C56-41A1-BAEB-CA5D5CED1A57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{415E011A-1C56-41A1-BAEB-CA5D5CED1A57}.Debug|Any CPU.Build.0 = Debug|Any CPU
{415E011A-1C56-41A1-BAEB-CA5D5CED1A57}.Release|Any CPU.ActiveCfg = Release|Any CPU
{415E011A-1C56-41A1-BAEB-CA5D5CED1A57}.Release|Any CPU.Build.0 = Release|Any CPU
{C554C480-3DA7-4D62-A09A-3F3F743D7A66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C554C480-3DA7-4D62-A09A-3F3F743D7A66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C554C480-3DA7-4D62-A09A-3F3F743D7A66}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C554C480-3DA7-4D62-A09A-3F3F743D7A66}.Release|Any CPU.Build.0 = Release|Any CPU
{37BC5B4A-3F96-4BB0-92E6-81666F4324E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{37BC5B4A-3F96-4BB0-92E6-81666F4324E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{37BC5B4A-3F96-4BB0-92E6-81666F4324E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{37BC5B4A-3F96-4BB0-92E6-81666F4324E4}.Release|Any CPU.Build.0 = Release|Any CPU
{F0C976EF-EE26-4EA9-B324-0CD21DCEA140}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F0C976EF-EE26-4EA9-B324-0CD21DCEA140}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0C976EF-EE26-4EA9-B324-0CD21DCEA140}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0C976EF-EE26-4EA9-B324-0CD21DCEA140}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1818,6 +1844,11 @@ Global
{091EA540-355B-4763-9980-5F83F0BB6F11} = {15966C27-17FA-4A46-A172-55985411540A}
{C60C5CFA-5B6D-4432-BFCD-54D1BEEC7DBE} = {830A89EC-4029-4753-B25A-068BAE37DEC7}
{6F71BC73-B703-4E64-98E0-801781302E7A} = {830A89EC-4029-4753-B25A-068BAE37DEC7}
{3FF3F00C-95C0-46FC-B2BE-A3920C71E393} = {D173887B-AF42-4576-B9C1-96B9E9B3D9C0}
{415E011A-1C56-41A1-BAEB-CA5D5CED1A57} = {3FF3F00C-95C0-46FC-B2BE-A3920C71E393}
{C554C480-3DA7-4D62-A09A-3F3F743D7A66} = {3FF3F00C-95C0-46FC-B2BE-A3920C71E393}
{37BC5B4A-3F96-4BB0-92E6-81666F4324E4} = {3FF3F00C-95C0-46FC-B2BE-A3920C71E393}
{F0C976EF-EE26-4EA9-B324-0CD21DCEA140} = {3FF3F00C-95C0-46FC-B2BE-A3920C71E393}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6DCEDFEC-988E-4CB3-B45B-191EB5086E0C}
Expand Down
9 changes: 5 additions & 4 deletions playground/TestShop/TestShop.AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
var builder = DistributedApplication.CreateBuilder(args);

var catalogDb = builder.AddPostgres("postgres")
.WithDataVolume()
.WithPgAdmin()
.AddDatabase("catalogdb");
var postgres = builder.AddPostgres("postgres")
.WithDataVolume()
.WithPgAdmin();

var catalogDb = postgres.AddDatabase("catalogdb");

var basketCache = builder.AddRedis("basketcache")
.WithDataVolume();
Expand Down
34 changes: 34 additions & 0 deletions playground/waitfor/WaitForSandbox.ApiService/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.EntityFrameworkCore;
using WaitForSandbox.Common;

var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();

builder.AddNpgsqlDbContext<MyDbContext>("db");

var app = builder.Build();

app.MapDefaultEndpoints();
app.MapGet("/", async (MyDbContext dbContext) =>
{
// We only work with db1Context for the rest of this
// since we've proven connectivity to the others for now.
var entry = new Entry();
await dbContext.Entries.AddAsync(entry);
await dbContext.SaveChangesAsync();

var entries = await dbContext.Entries.ToListAsync();

return new
{
totalEntries = entries.Count,
entries = entries
};
});

app.Run();

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5180",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<AspireProjectOrPackageReference Include="Aspire.Npgsql.EntityFrameworkCore.PostgreSQL" />
<ProjectReference Include="..\..\Playground.ServiceDefaults\Playground.ServiceDefaults.csproj" />
<ProjectReference Include="..\WaitForSandbox.Common\WaitForSandbox.Common.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@CosmosEndToEnd.ApiService_HostAddress = http://localhost:5193

GET {{SqlServerEndToEnd.ApiService_HostAddress}}/weatherforecast/
Accept: application/json

###
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions playground/waitfor/WaitForSandbox.ApiService/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
31 changes: 31 additions & 0 deletions playground/waitfor/WaitForSandbox.AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

var builder = DistributedApplication.CreateBuilder(args);

var pg = builder.AddPostgres("pg")
.AsAzurePostgresFlexibleServer()
.WithPgAdmin();

var db = pg.AddDatabase("db");

var dbsetup = builder.AddProject<Projects.WaitForSandbox_DbSetup>("dbsetup")
.WithReference(db)
.WaitFor(pg);

builder.AddProject<Projects.WaitForSandbox_ApiService>("api")
.WithExternalHttpEndpoints()
.WaitForCompletion(dbsetup)
.WithReference(db);

#if !SKIP_DASHBOARD_REFERENCE
// This project is only added in playground projects to support development/debugging
// of the dashboard. It is not required in end developer code. Comment out this code
// or build with `/p:SkipDashboardReference=true`, to test end developer
// dashboard launch experience, Refer to Directory.Build.props for the path to
// the dashboard binary (defaults to the Aspire.Dashboard bin output in the
// artifacts dir).
builder.AddProject<Projects.Aspire_Dashboard>(KnownResourceNames.AspireDashboard);
#endif

builder.Build().Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:15887;http://localhost:15888",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:16175",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:17037",
"DOTNET_ASPIRE_SHOW_DASHBOARD_RESOURCES": "true"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15888",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16175",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:17038",
"DOTNET_ASPIRE_SHOW_DASHBOARD_RESOURCES": "true",
"ASPIRE_ALLOW_UNSECURED_TRANSPORT": "true"
}
},
"generate-manifest": {
"commandName": "Project",
"launchBrowser": true,
"dotnetRunMessages": true,
"commandLineArgs": "--publisher manifest --output-path aspire-manifest.json",
"applicationUrl": "http://localhost:15888",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16175"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
<UserSecretsId>9776201d-1036-4111-8b0a-7e8a520ea26c</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\..\KnownResourceNames.cs" Link="KnownResourceNames.cs" />
</ItemGroup>

<ItemGroup>
<AspireProjectOrPackageReference Include="Aspire.Hosting.AppHost" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.PostgreSQL" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.Azure.PostgreSQL" />

<ProjectReference Include="..\WaitForSandbox.ApiService\WaitForSandbox.ApiService.csproj" />

<ProjectReference Include="..\WaitForSandbox.DbSetup\WaitForSandbox.DbSetup.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions playground/waitfor/WaitForSandbox.AppHost/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}
100 changes: 100 additions & 0 deletions playground/waitfor/WaitForSandbox.AppHost/aspire-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"$schema": "https://json.schemastore.org/aspire-8.0.json",
"resources": {
"pg": {
"type": "azure.bicep.v0",
"connectionString": "{pg.secretOutputs.connectionString}",
"path": "pg.module.bicep",
"params": {
"keyVaultName": "",
"administratorLogin": "{pg-username.value}",
"administratorLoginPassword": "{pg-password.value}"
}
},
"db": {
"type": "value.v0",
"connectionString": "{pg.connectionString};Database=db"
},
"dbsetup": {
"type": "project.v0",
"path": "../WaitForSandbox.DbSetup/WaitForSandbox.DbSetup.csproj",
"env": {
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory",
"ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true",
"HTTP_PORTS": "{dbsetup.bindings.http.targetPort}",
"ConnectionStrings__db": "{db.connectionString}"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http"
},
"https": {
"scheme": "https",
"protocol": "tcp",
"transport": "http"
}
}
},
"api": {
"type": "project.v0",
"path": "../WaitForSandbox.ApiService/WaitForSandbox.ApiService.csproj",
"env": {
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory",
"ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true",
"HTTP_PORTS": "{api.bindings.http.targetPort}",
"ConnectionStrings__db": "{db.connectionString}"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http",
"external": true
},
"https": {
"scheme": "https",
"protocol": "tcp",
"transport": "http",
"external": true
}
}
},
"pg-username": {
"type": "parameter.v0",
"value": "{pg-username.inputs.value}",
"inputs": {
"value": {
"type": "string",
"default": {
"generate": {
"minLength": 10,
"numeric": false,
"special": false
}
}
}
}
},
"pg-password": {
"type": "parameter.v0",
"value": "{pg-password.inputs.value}",
"inputs": {
"value": {
"type": "string",
"secret": true,
"default": {
"generate": {
"minLength": 22
}
}
}
}
}
}
}
Loading
Loading