Only fire BeforeResourceStartedEvent when actually starting a resource#13519
Only fire BeforeResourceStartedEvent when actually starting a resource#13519
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13519Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13519" |
|
@copilot add unit tests to |
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue where BeforeResourceStartedEvent was being fired during resource creation even for resources marked with ExplicitStartupAnnotation. The change ensures this event only fires when a resource is actually starting, not when it's simply being created with the intention to start it manually later.
Key Changes
- Modified
CreateResourceExecutablesAsyncCoreto check forExplicitStartupAnnotationand skip publishingOnResourceStartingContextfor such resources - Modified
CreateContainerAsyncto apply the same explicit startup check for container resources - Added logic to set the resource state to "NotStarted" when explicit startup is configured
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ources (#13520) * Initial plan * Add unit tests for BeforeResourceStartedEvent with explicit start resources Co-authored-by: danegsta <50252651+danegsta@users.noreply.github.com> * Refactor tests to use OnBeforeResourceStarted callbacks with Interlocked.Increment Co-authored-by: danegsta <50252651+danegsta@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: danegsta <50252651+danegsta@users.noreply.github.com>
|
@afscrome I may have called you out as "afscrome is going to be really happy to see this PR" when we were discussing this change in a team chat. |
Description
We currently fire
BeforeResourceStartedEventwhen creating resources even if a resource is set to explicit start. This means the event can't be used to reliably do work only before a resource is actually starting without doing ref counting. This change skips firing the initial event if the resource is marked for explicit startup.Fixes #13068
Fixes #13070