Skip to content

Enforce explicit compute environment binding - #16411

Merged
Eric Erhardt (eerhardt) merged 5 commits into
microsoft:mainfrom
eerhardt:ThrowForMultipleComputeEnvironments
Apr 28, 2026
Merged

Eric Erhardt (eerhardt) merged 5 commits into
microsoft:mainfrom
eerhardt:ThrowForMultipleComputeEnvironments

Conversation

@eerhardt

Copy link
Copy Markdown
Member

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.

@github-actions

github-actions Bot commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16411

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16411"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.EnsureComputeEnvironmentAnnotationsApplied to throw when multiple compute environments exist and any IComputeResource lacks a ComputeEnvironmentAnnotation.
  • 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.

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.
@eerhardt
Eric Erhardt (eerhardt) force-pushed the ThrowForMultipleComputeEnvironments branch from fbb91be to 77407ff Compare April 28, 2026 18:59
@eerhardt
Eric Erhardt (eerhardt) merged commit 19f1b16 into microsoft:main Apr 28, 2026
563 of 567 checks passed
@eerhardt
Eric Erhardt (eerhardt) deleted the ThrowForMultipleComputeEnvironments branch April 28, 2026 21:58
@github-actions github-actions Bot added this to the 13.3 milestone Apr 28, 2026
Nell Shamrell-Harrington (nellshamrell) pushed a commit to nellshamrell/aspire that referenced this pull request May 18, 2026
* Enforce explicit compute environment binding

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.

* Move the compute environment validation to a pipeline step

* add partition

* Revert comments

* Rename pipeline step
@github-actions github-actions Bot locked and limited conversation to collaborators May 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants