Skip to content

Update parent resource state from replicas - #18642

Merged
Adam Ratzman (adamint) merged 24 commits into
microsoft:mainfrom
adamint:adamint-fix-resource-replica-state
Aug 18, 2026
Merged

Adam Ratzman (adamint) merged 24 commits into
microsoft:mainfrom
adamint:adamint-fix-resource-replica-state

Conversation

@adamint

@adamint Adam Ratzman (adamint) commented Jul 4, 2026 •

Copy link
Copy Markdown
Member

Description

Fixes #13909

Dashboard resource rows can now reflect the state of their replica child rows. This fixes the deployed Azure Container Apps case where the logical container app row stayed Scaled to zero even after one of its replica rows reported Running.

The resources page now recomputes the parent row state for nested replica rows that share the parent display name, while leaving ordinary child resources alone. It also keeps the raw resource snapshot separate from the derived display row so the parent can fall back to Scaled to zero after the last running replica is deleted.

The regression tests cover initial snapshot propagation, update-stream propagation, restore-on-delete, replica health updates, mixed-health running replicas, state-owned property updates such as exit code and timestamps, and the non-replica child case.

HasSameDisplayedReplicaState decides whether a replica change is worth re-emitting the parent row for, and it compares more than State: styling, timestamps, health status, health reports, and the state-owned properties. Every test that exercised those fields did so through the initial snapshot, where the comparison never runs. Five subscription tests close those gaps:

  • SubscribeResources_ReplicaHealthChanged_EmitsParentHealthChange — the replica stays Running and only its health report flips Healthy to Unhealthy.
  • SubscribeResources_ReplicaStateOwnedPropertyChanged_EmitsParentChange — the replica stays Exited and only its exit code changes.
  • SubscribeResources_ReplicaStateStyleChanged_EmitsParentChange — the replica stays Running and only its state style changes.
  • SubscribeResources_ReplicaStartedAtChanged_EmitsParentChange — the replica stays Running and only its start timestamp changes.
  • SubscribeResources_ReplicaStoppedAtChanged_EmitsParentChange — the replica stays Exited and only its stop timestamp changes.

All five are mutation-proved. Removing the two health clauses fails the health test, removing HasSameStateOwnedProperties fails the exit-code test, and removing any styling or timestamp clause fails its matching same-state test.

Screenshots / Recordings

No live ACA scale-to-zero recording is attached. The issue screenshots show the before state, and the added component tests cover the parent/replica state update behavior.

Validation

DOTNET_CLI_UI_LANGUAGE=en-US ./.dotnet/dotnet test --project tests/Aspire.Dashboard.Tests/Aspire.Dashboard.Tests.csproj --no-restore --no-launch-profile -- --filter-method "*.GetResources_ReplicaRunning_ReturnsParentWithReplicaState" --filter-method "*.GetResources_MultipleRunningReplicas_UsesLeastHealthyReplicaForParentHealth" --filter-method "*.GetResources_ChildResourceWithDifferentDisplayName_DoesNotUpdateParentState" --filter-method "*.SubscribeResources_ReplicaUpdated_EmitsParentStateChange" --filter-method "*.SubscribeResources_ReplicaDeleted_EmitsParentFallbackState" --filter-method "*.SubscribeResources_ReplicaHealthChanged_EmitsParentHealthChange" --filter-method "*.SubscribeResources_ReplicaStateOwnedPropertyChanged_EmitsParentChange" --filter-method "*.SubscribeResources_ReplicaStateStyleChanged_EmitsParentChange" --filter-method "*.SubscribeResources_ReplicaStartedAtChanged_EmitsParentChange" --filter-method "*.SubscribeResources_ReplicaStoppedAtChanged_EmitsParentChange" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"
DOTNET_CLI_UI_LANGUAGE=en-US ./.dotnet/dotnet test --project tests/Aspire.Dashboard.Components.Tests/Aspire.Dashboard.Components.Tests.csproj --no-restore --no-launch-profile -- --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"
DOTNET_CLI_UI_LANGUAGE=en-US ./.dotnet/dotnet test --project tests/Aspire.Dashboard.Tests/Aspire.Dashboard.Tests.csproj --no-restore --no-launch-profile -- --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

Copilot AI balanced review requested due to automatic review settings July 4, 2026 15:49
@github-actions

github-actions Bot commented Jul 4, 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 -- 18642

Or

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

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

Updates the Dashboard resources page so a “parent” resource row can reflect state changes reported by its replica child rows (specifically for nested replica rows sharing the parent display name), fixing the Azure Container Apps “Scaled to zero” row not updating when a replica becomes “Running”.

Changes:

  • Recompute parent row state from matching replica child rows during initial snapshot and subsequent resource change batches.
  • Add ResourceViewModel.WithStateFrom(...) to clone a view model while overriding state-related fields.
  • Add a bUnit regression test covering the parent/replica state update scenario from #13909.
Show a summary per file
File Description
tests/Aspire.Dashboard.Components.Tests/Pages/ResourcesTests.cs Adds regression test for parent state reflecting replica updates; extends test helpers to model replica display name + parent-name property.
src/Aspire.Dashboard/Model/ResourceViewModel.cs Adds helper to copy state-related fields from a replica to a parent while preserving the rest of the view model.
src/Aspire.Dashboard/Components/Pages/Resources.razor.cs Implements parent/replica state recomputation on snapshot and on update batches; defines replica-child detection logic.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Low

Copilot AI review requested due to automatic review settings July 4, 2026 16:17

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.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Medium

Copilot AI review requested due to automatic review settings July 4, 2026 17:08

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.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Medium

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Copilot AI review requested due to automatic review settings July 21, 2026 20:32
@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Adam Ratzman (adamint) added a commit to adamint/aspire that referenced this pull request Jul 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@adamint Adam Ratzman (adamint) modified the milestones: 13.5, Backlog Jul 28, 2026
Copilot AI review requested due to automatic review settings August 11, 2026 03:50

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.

Review details

  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@adamint
Adam Ratzman (adamint) marked this pull request as ready for review August 11, 2026 04:25
@adamint
Adam Ratzman (adamint) marked this pull request as draft August 11, 2026 21:15
Co-authored-by: Copilot <[email protected]>
Copilot-Session: c15db581-f525-4089-a34f-2e8f4b021465
Copilot AI review requested due to automatic review settings August 14, 2026 22:32

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.

Review details

  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Adam Ratzman and others added 5 commits August 17, 2026 22:03
Co-authored-by: Copilot <[email protected]>
Copilot-Session: ed40fedd-e392-4643-ba83-09245cc58bb0
Co-authored-by: Copilot <[email protected]>
Copilot-Session: ed40fedd-e392-4643-ba83-09245cc58bb0
Co-authored-by: Copilot <[email protected]>
Copilot-Session: ed40fedd-e392-4643-ba83-09245cc58bb0
Co-authored-by: Copilot <[email protected]>

Copilot-Session: ed40fedd-e392-4643-ba83-09245cc58bb0
Co-authored-by: Copilot <[email protected]>

Copilot-Session: ed40fedd-e392-4643-ba83-09245cc58bb0
Copilot AI review requested due to automatic review settings August 18, 2026 04:29

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.

Review details

  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

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.

I reviewed the parent/replica state projection end to end, including source/display model ownership, replica selection and fallback, update-stream diffing, hidden-state behavior, projected properties and health, all IDashboardClient consumers, the stress scenario, and regression coverage.

I didn't find any concrete correctness issues or nonblocking comments to leave.

@JamesNK

Copy link
Copy Markdown
Member

I don't think it is the dashboard's job to update resources. It's a dumb view of what the app host tells it to do. If resource state is wrong then it should be fixed in the app host and then the dashboard just displays what it's told to.

Adam Ratzman (@adamint)

Adam Ratzman (adamint) added a commit that referenced this pull request Aug 20, 2026
This reverts commit 5639ea2.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: c76af9f5-7190-41f8-a761-70ba462e9e55
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resource state isn't updating on replica state

4 participants