Fix replica parent resource state#18641
Draft
adamint wants to merge 2 commits into
Draft
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 18641Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 18641" |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a Resources-page state inconsistency where an Azure Container App parent row could remain stuck on a custom scale-to-zero state even after one of its replicas woke up and became Running. It does this by keeping the raw resource snapshots separate from a derived "effective" view: when a nested replica (same ParentName and display name) is Running, the parent row is projected as Running; when replicas scale back down, the parent reverts to its own snapshot state.
Changes:
- Split resource storage into
_rawResourceByName(source-of-truth snapshots) and_resourceByName(effective/derived view), and rebuild the effective view viaUpdateEffectiveResourceStateCache/TryCreateEffectiveReplicaParentResource/CanShowReplicaRunningState. - Added
ResourceViewModel.WithState(...)to clone a resource with overriddenState/StateStyle/KnownState, and refreshed the selected resource to its effective projection so the details view stays in sync. - Added a component test covering the parent-tracks-running-child transition and its revert.
Show a summary per file
| File | Description |
|---|---|
| src/Aspire.Dashboard/Components/Pages/Resources.razor.cs | Introduces raw vs. effective resource caches and derives parent state from running child replicas; keeps the selected resource projection in sync. |
| src/Aspire.Dashboard/Model/ResourceViewModel.cs | Adds internal WithState helper to produce a state-overridden copy while preserving all other properties. |
| tests/Aspire.Dashboard.Components.Tests/Pages/ResourcesTests.cs | Adds a test for the parent-follows-running-child behavior plus displayName/CreateParentProperties test helpers. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Medium
Comment on lines
382
to
394
| UpdateEffectiveResourceStateCache(); | ||
|
|
||
| foreach (var effectiveResource in _resourceByName.Values) | ||
| { | ||
| PageViewModel.ResourceTypesToVisibility.AddOrUpdate(resource.ResourceType, resourceTypeVisible(resource.ResourceType), (_, _) => resourceTypeVisible(resource.ResourceType)); | ||
| // Don't add Parameter to resource type filters. Parameters have their own dedicated view | ||
| // and are excluded from the Table and Graph views regardless of the type filter. | ||
| if (!effectiveResource.IsParameter) | ||
| { | ||
| PageViewModel.ResourceTypesToVisibility.AddOrUpdate(effectiveResource.ResourceType, resourceTypeVisible(effectiveResource.ResourceType), (_, _) => resourceTypeVisible(effectiveResource.ResourceType)); | ||
| } | ||
| PageViewModel.ResourceStatesToVisibility.AddOrUpdate(effectiveResource.State ?? string.Empty, stateVisible(effectiveResource.State ?? string.Empty), (_, _) => stateVisible(effectiveResource.State ?? string.Empty)); | ||
| PageViewModel.ResourceHealthStatusesToVisibility.AddOrUpdate(effectiveResource.HealthStatus?.Humanize() ?? string.Empty, healthStatusVisible(effectiveResource.HealthStatus?.Humanize() ?? string.Empty), (_, _) => healthStatusVisible(effectiveResource.HealthStatus?.Humanize() ?? string.Empty)); | ||
| } |
| }; | ||
| } | ||
|
|
||
| private static ImmutableDictionary<string, ResourcePropertyViewModel> CreateParentProperties(string parentName) |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.
Description
The dashboard could show a replica as
Runningwhile the parent resource row stayed stuck on a custom scale-to-zero state. That made Azure Container Apps with min replicas set to 0 look idle even after traffic woke up a replica.This keeps the original resource snapshots around and derives an effective parent state for the Resources page: if a nested replica with the same display name is
Running, the parent row is shown asRunning; when replicas scale back down, the parent goes back to its own snapshot state.The follow-up fix from review keeps effective state out of the raw resource cache so query/filter refreshes cannot make the parent stay
Runningafter the replica disappears.Screenshots / Recordings
TODO: Capture an ACA scale-to-zero resource before/after. The scenario to verify is an Azure Container App parent row that starts as
Scaled to zero, receives traffic, and has a child replica transition toRunning.User-facing usage
Users do not need to change anything. On the Resources page, a scale-to-zero parent resource now reflects a running child replica instead of continuing to look scaled down.
Validation
Passed locally on
16f1f93f7049c6b4e80642bd373ccbec7d00eef1:Review fleet completed. The high-confidence raw/effective cache finding was fixed and covered by regression tests.
Resolves #13909
Checklist
<remarks />and<code />elements on your triple slash comments?