-
Notifications
You must be signed in to change notification settings - Fork 659
Fire ResourceEndpointsAllocatedEvent event once for each logical app model resource #10548
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
Conversation
There was a problem hiding this comment.
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 fixes duplicate URL entries in the dashboard for resources with replicas by ensuring the ResourceEndpointsAllocatedEvent is fired only once per logical app model resource instead of once per replica. The fix involves two main improvements: adding deduplication logic when firing events and making the URL processing callback idempotent to prevent duplicate URL entries.
Key changes:
- Added event deduplication to fire ResourceEndpointsAllocatedEvent only once per logical resource
- Made ProcessResourceUrlCallbacks idempotent by checking existing URLs before adding new ones
- Refactored URL generation logic with clearer switch expression pattern for better maintainability
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/Aspire.Hosting/Dcp/DcpExecutor.cs | Added HashSet-based deduplication to ensure ResourceEndpointsAllocatedEvent fires once per resource name |
src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs | Refactored ProcessResourceUrlCallbacks to be idempotent and improved URL generation logic with switch expressions |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Any way to test this? |
I’ll add a WithReplicas scenario to the existing URL tests. |
Added test coverage (the new test fails on main, but passes on this branch) |
urls.Add(url); | ||
if (allocatedEndpoint.BindingMode != EndpointBindingMode.SingleAddress && (endpoint.TargetHost is not "localhost" or "127.0.0.1")) | ||
|
||
// In the case that a service is bound to multiple addresses or a *.localhost address, we generate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting is busted here, but I can't tweak 😢 (forks!!!)
/backport to release/9.4 |
Started backporting to release/9.4: https://github.com/dotnet/aspire/actions/runs/16436550843 |
Description
Prevent duplicating URLs in the dashboard for resources with replicas.
We were firing ResourceEndpointsAllocatedEvent once for each replica instead of once for the logical app model resource. Additionally, ProcessResourceUrlCallbacks wasn't idempotent and would result in the same endpoint URLs being added every time it was called.
Fixes #10529