Ensure compute environment prepare waits for validation - #16580
Conversation
When Foundry is used with another compute environment, the compute environments get confused about who takes ownership of which compute. Make all compute-environment prepare pipeline steps depend on the shared validate-compute-environments step so before-start cannot race environment validation. Add diagnostics coverage for a mixed Foundry hosted-agent and Azure Container Apps app. Cover deployment target lookup returning null for a different compute environment.
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16580Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16580" |
There was a problem hiding this comment.
Pull request overview
This PR addresses a publish/deploy pipeline race where compute-environment “prepare” steps could run in parallel with compute-environment validation, leading to ambiguous ownership when multiple compute environments (e.g., Foundry + ACA/App Service) are present.
Changes:
- Introduces a well-known pipeline step name for
validate-compute-environmentsand uses it in the core pipeline definition. - Makes compute-environment “prepare” steps depend on
validate-compute-environments, ensuring validation completes before prepare can materialize deployment targets. - Adds/updates tests and snapshots, including diagnostics coverage for a mixed Foundry hosted-agent + Azure Container Apps scenario, and adds a null-return case for deployment-target lookup with a mismatched compute environment.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Hosting.Tests/ResourceExtensionsTests.cs | Adds a unit test ensuring deployment-target lookup returns null when the requested compute environment doesn’t match the annotation’s compute environment. |
| tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureDeployerTests.DeployAsync_WithRedisAccessKeyAuthentication_CreatesCorrectDependencies.verified.txt | Updates expected pipeline diagnostics to reflect prepare-* depending on validate-compute-environments. |
| tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureDeployerTests.DeployAsync_WithPrivateEndpoints_CreatesCorrectDependencies.verified.txt | Updates expected dependency graph ordering/dependencies to include validate-compute-environments as a prerequisite for prepare. |
| tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureDeployerTests.DeployAsync_WithMultipleComputeEnvironments_Works_step=diagnostics.verified.txt | Updates multi-environment diagnostics snapshot to show validation preceding prepare steps. |
| tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureDeployerTests.DeployAsync_WithFoundryAndAzureContainerApps_CreatesCorrectDependencies.verified.txt | Adds a new diagnostics snapshot for mixed Foundry + ACA compute environments. |
| tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureDeployerTests.DeployAsync_WithAzureResourceDependencies_DoesNotHang_step=diagnostics.verified.txt | Updates snapshot to reflect new dependency from prepare to compute-environment validation. |
| tests/Aspire.Hosting.Azure.Tests/AzureDeployerTests.cs | Adds an integration-style diagnostics test for Foundry hosted-agent + ACA to validate step graph dependencies. |
| src/Aspire.Hosting/Pipelines/WellKnownPipelineSteps.cs | Adds ValidateComputeEnvironments constant for consistent step naming. |
| src/Aspire.Hosting/Pipelines/DistributedApplicationPipeline.cs | Switches the validate step name from a literal to the new well-known constant. |
| src/Aspire.Hosting/ApplicationModel/ResourceExtensions.cs | Updates GetDeploymentTargetAnnotation to return null when a requested compute environment doesn’t match the annotation’s compute environment. |
| src/Aspire.Hosting.Kubernetes/KubernetesEnvironmentResource.cs | Makes Kubernetes prepare-deployment-targets step depend on compute-environment validation. |
| src/Aspire.Hosting.Foundry/Project/ProjectResource.cs | Makes Foundry project prepare step depend on compute-environment validation. |
| src/Aspire.Hosting.Foundry/HostedAgent/HostedAgentBuilderExtension.cs | Ensures hosted-agent published resources are explicitly bound to the Foundry project compute environment. |
| src/Aspire.Hosting.Foundry/HostedAgent/AzureHostedAgentResource.cs | Removes IComputeResource from AzureHostedAgentResource’s implemented interfaces. |
| src/Aspire.Hosting.Docker/DockerComposeEnvironmentResource.cs | Makes Docker Compose prepare steps depend on compute-environment validation. |
| src/Aspire.Hosting.Azure.Kubernetes/AzureKubernetesEnvironmentResource.cs | Makes AKS prepare step depend on compute-environment validation. |
| src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentResource.cs | Makes App Service environment prepare step depend on compute-environment validation. |
| src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppEnvironmentResource.cs | Makes ACA environment prepare step depend on compute-environment validation. |
| playground/FoundryAgents/FoundryAgents.AppHost/FoundryAgents.AppHost.csproj | Adds AppContainers hosting package reference for the updated playground scenario. |
| playground/FoundryAgents/FoundryAgents.AppHost/AppHost.cs | Updates playground to include an ACA environment and bind a project to it alongside Foundry usage. |
|
Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
|
|
/backport to release/13.3 |
|
Started backporting to |
|
Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
|
|
🎬 CLI E2E Test Recordings — 76 recordings uploaded (commit View all recordings
📹 Recordings uploaded automatically from CI run #25138492717 |
|
No documentation PR is required for this change. This PR is a bug fix that ensures compute-environment prepare pipeline steps wait for the shared
|
) * Ensure compute environment prepare waits for validation When Foundry is used with another compute environment, the compute environments get confused about who takes ownership of which compute. Make all compute-environment prepare pipeline steps depend on the shared validate-compute-environments step so before-start cannot race environment validation. Add diagnostics coverage for a mixed Foundry hosted-agent and Azure Container Apps app. Cover deployment target lookup returning null for a different compute environment. * Fix tests
When Foundry is used with another compute environment, the compute environments get confused about who takes ownership of which compute.
Make all compute-environment prepare pipeline steps depend on the shared validate-compute-environments step so before-start cannot race environment validation.
Add diagnostics coverage for a mixed Foundry hosted-agent and Azure Container Apps app.
Cover deployment target lookup returning null for a different compute environment.