Enforce explicit compute environment binding#16411
Open
eerhardt wants to merge 4 commits intomicrosoft:mainfrom
Open
Enforce explicit compute environment binding#16411eerhardt wants to merge 4 commits intomicrosoft:mainfrom
eerhardt wants to merge 4 commits intomicrosoft:mainfrom
Conversation
Throw if compute resources are unbound when multiple compute environments exist, preventing ambiguous deployments. Update summary comments to clarify behavior. Add tests to verify exception is thrown for unbound resources, no exception when all are bound, and auto-binding with a single environment.
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16411Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16411" |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR restores/strengthens compute-environment disambiguation in the hosting model by failing fast when multiple compute environments exist but one or more compute resources are left unbound, avoiding ambiguous (or inconsistent) deployment targeting.
Changes:
- Add validation in
DistributedApplication.EnsureComputeEnvironmentAnnotationsAppliedto throw when multiple compute environments exist and anyIComputeResourcelacks aComputeEnvironmentAnnotation. - Update the XML documentation on compute-environment annotation application/validation behavior.
- Add unit tests covering: throw-on-unbound with multiple environments, no-throw when all bound, and auto-binding when a single environment exists.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Aspire.Hosting/DistributedApplication.cs | Adds multi-environment validation (throw on unbound compute resources) and updates the documentation for compute-environment binding behavior. |
| tests/Aspire.Hosting.Tests/ComputeEnvironmentValidationTests.cs | Introduces targeted unit tests for the multi/single environment binding and validation behavior. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Throw if compute resources are unbound when multiple compute environments exist, preventing ambiguous deployments. Update summary comments to clarify behavior. Add tests to verify exception is thrown for unbound resources, no exception when all are bound, and auto-binding with a single environment.
This was the behavior originally in Allow multiple compute environment resources in an app model (microsoft/aspire#8820). However, Fix: Skip resources targeted to different compute environments (microsoft/aspire#14177) broke this behavior to no longer throw - and compute resources silently were ignored.