-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aspire: Fix panic when a project has no endpoints (#4065)
* aspire: Fix panic when a project has no endpoints Worker projects do not expose endpoints and hence do not need ingress configured on their container apps. We had a bug in constructing the template context in the case where a project did not have and endpoints. To address this, we only set `TargetPortExpression` in the case where we have Ingress configured. `TargetPortExpression` is only used in the template when the service has ingress, so the empty value will cause no harm in cases where the service has not configured ingress. Fixes #4064
- Loading branch information
Showing
17 changed files
with
2,313 additions
and
929 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
cli/azd/pkg/apphost/testdata/TestAspireEscaping-worker.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
api-version: 2024-02-02-preview | ||
location: {{ .Env.AZURE_LOCATION }} | ||
identity: | ||
type: UserAssigned | ||
userAssignedIdentities: | ||
? "{{ .Env.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID }}" | ||
: {} | ||
properties: | ||
environmentId: {{ .Env.AZURE_CONTAINER_APPS_ENVIRONMENT_ID }} | ||
configuration: | ||
activeRevisionsMode: single | ||
runtime: | ||
dotnet: | ||
autoConfigureDataProtection: true | ||
registries: | ||
- server: {{ .Env.AZURE_CONTAINER_REGISTRY_ENDPOINT }} | ||
identity: {{ .Env.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID }} | ||
template: | ||
containers: | ||
- image: {{ .Image }} | ||
name: worker | ||
env: | ||
- name: AZURE_CLIENT_ID | ||
value: {{ .Env.MANAGED_IDENTITY_CLIENT_ID }} | ||
- name: OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES | ||
value: "true" | ||
- name: OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES | ||
value: "true" | ||
scale: | ||
minReplicas: 1 | ||
tags: | ||
azd-service-name: worker | ||
aspire-resource-name: worker | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 31 additions & 14 deletions
45
cli/azd/test/functional/testdata/recordings/Test_CLI_VsServer/LiveDeployRefresh.dotnet.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
3,012 changes: 2,104 additions & 908 deletions
3,012
cli/azd/test/functional/testdata/recordings/Test_CLI_VsServer/LiveDeployRefresh.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...unctional/testdata/samples/aspire-full/AspireAzdTests.Worker/AspireAzdTests.Worker.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Worker"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<UserSecretsId>dotnet-AspireAzdTests.Worker-7ae08e90-5023-4396-8dd7-b0b52bf65c9a</UserSecretsId> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\AspireAzdTests.ServiceDefaults\AspireAzdTests.ServiceDefaults.csproj" /> | ||
</ItemGroup> | ||
</Project> |
7 changes: 7 additions & 0 deletions
7
cli/azd/test/functional/testdata/samples/aspire-full/AspireAzdTests.Worker/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using AspireAzdTests.Worker; | ||
|
||
var builder = Host.CreateApplicationBuilder(args); | ||
builder.Services.AddHostedService<Worker>(); | ||
|
||
var host = builder.Build(); | ||
host.Run(); |
12 changes: 12 additions & 0 deletions
12
...ctional/testdata/samples/aspire-full/AspireAzdTests.Worker/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"profiles": { | ||
"AspireAzdTests.Worker": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"environmentVariables": { | ||
"DOTNET_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
cli/azd/test/functional/testdata/samples/aspire-full/AspireAzdTests.Worker/Worker.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace AspireAzdTests.Worker; | ||
|
||
public class Worker : BackgroundService | ||
{ | ||
private readonly ILogger<Worker> _logger; | ||
|
||
public Worker(ILogger<Worker> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
protected override async Task ExecuteAsync(CancellationToken stoppingToken) | ||
{ | ||
while (!stoppingToken.IsCancellationRequested) | ||
{ | ||
if (_logger.IsEnabled(LogLevel.Information)) | ||
{ | ||
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); | ||
} | ||
await Task.Delay(1000, stoppingToken); | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...unctional/testdata/samples/aspire-full/AspireAzdTests.Worker/appsettings.Development.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.Hosting.Lifetime": "Information" | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
cli/azd/test/functional/testdata/samples/aspire-full/AspireAzdTests.Worker/appsettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.Hosting.Lifetime": "Information" | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
.../test/functional/testdata/snaps/aspire-full/AspireAzdTests.AppHost/infra/worker.tmpl.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
api-version: 2024-02-02-preview | ||
location: {{ .Env.AZURE_LOCATION }} | ||
identity: | ||
type: UserAssigned | ||
userAssignedIdentities: | ||
? "{{ .Env.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID }}" | ||
: {} | ||
properties: | ||
environmentId: {{ .Env.AZURE_CONTAINER_APPS_ENVIRONMENT_ID }} | ||
configuration: | ||
activeRevisionsMode: single | ||
runtime: | ||
dotnet: | ||
autoConfigureDataProtection: true | ||
registries: | ||
- server: {{ .Env.AZURE_CONTAINER_REGISTRY_ENDPOINT }} | ||
identity: {{ .Env.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID }} | ||
template: | ||
containers: | ||
- image: {{ .Image }} | ||
name: worker | ||
env: | ||
- name: AZURE_CLIENT_ID | ||
value: {{ .Env.MANAGED_IDENTITY_CLIENT_ID }} | ||
- name: OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES | ||
value: "true" | ||
- name: OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES | ||
value: "true" | ||
- name: OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY | ||
value: in_memory | ||
scale: | ||
minReplicas: 1 | ||
tags: | ||
azd-service-name: worker | ||
aspire-resource-name: worker | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters