Skip to content
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

[release/8.0] Dashboard should request log streams only when the user gestures to display them #3343

Merged
merged 1 commit into from
Apr 4, 2024

Conversation

eerhardt
Copy link
Member

@eerhardt eerhardt commented Apr 2, 2024

Customer Impact

Currently the dashboard requests log streams for all application resources at the startup or shortly after. This is not efficient, especially for Containers, where each log stream is associated with a separate container orchestrator (CLI) running in the background.

If you have many projects and containers running in your app, these unnecessary background processes use resources on your machine.

Testing

I manually tested launching an app, switching between console logs. Ensuring that after no longer viewing a container's console logs, the docker logs process goes away.

Existing tests pass. Added new unit tests.

Risk

Medium-low. This changes how console logs are streamed from DCP to the AppHost to the Dashboard.


Change the AppHost to only subscribe to DCP's logs when there is a subscriber for the logs.

Fix #2789

  • Show logs

  • Remove the "StreamingLogger" because that causes subsequent subscribers to not see what was already written.

Fix duplicate logs issue by clearing out the backlog when the last subscriber leaves.

  • Fix a concurrency issue with the backlog. Ensure the backlog is only snap shotted after subscribing to the log.

Fix existing tests for new functionality and add an additional test.

  • PR feedback

Only clear the backlog on containers and executables.

  • PR feedback.

Move lock out of async iterator.

  • Clean up code.
  • Remove count and instead check if the delegate is null to indicate whether there are subscribers or not.
  • Remove the separate IAsyncEnumerable classes and just use async IAsyncEnumerable methods.
  • Fix a race at startup when logs aren't available.

Employ a 2nd loop that listens for both "has subscribers" and "logs available".

  • Simplify ResourceNotificationService.WatchAsync.

  • Fix test build

  • Address PR feedback

  • Set SingleReader=true on the logInformationChannel.
  • Add comment and assert that LogsAvailable can only turn true and can't go back to false.

Microsoft Reviewers: Open in CodeFlow

…isplay them (dotnet#3235)

Change the AppHost to only subscribe to DCP's logs when there is a subscriber for the logs.

Fix dotnet#2789

* Show logs

* Remove the "StreamingLogger" because that causes subsequent subscribers to not see what was already written.

Fix duplicate logs issue by clearing out the backlog when the last subscriber leaves.

* Fix a concurrency issue with the backlog. Ensure the backlog is only snap shotted after subscribing to the log.

Fix existing tests for new functionality and add an additional test.

* PR feedback

Only clear the backlog on containers and executables.

* PR feedback.

Move lock out of async iterator.

* Clean up code.

- Remove count and instead check if the delegate is null to indicate whether there are subscribers or not.
- Remove the separate IAsyncEnumerable classes and just use `async IAsyncEnumerable` methods.

* Fix a race at startup when logs aren't available.

Employ a 2nd loop that listens for both "has subscribers" and "logs available".

* Simplify ResourceNotificationService.WatchAsync.

* Fix test build

* Address PR feedback

- Set SingleReader=true on the logInformationChannel.
- Add comment and assert that LogsAvailable can only turn true and can't go back to false.

---------

Co-authored-by: David Fowler <[email protected]>
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Apr 2, 2024
Copy link
Member

@joperezr joperezr left a comment

Choose a reason for hiding this comment

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

Approved in chat.

@joperezr joperezr added the Servicing-approved Approved for servicing release label Apr 3, 2024
@eerhardt
Copy link
Member Author

eerhardt commented Apr 4, 2024

@mitchdenny @karolz-ms - can I get 1 more approval on this? Need to merge into the release branch.

@eerhardt eerhardt merged commit 14b23a1 into dotnet:release/8.0 Apr 4, 2024
8 checks passed
@eerhardt eerhardt deleted the PortLogStreamChange branch April 4, 2024 02:56
@danmoseley danmoseley mentioned this pull request Apr 12, 2024
@github-actions github-actions bot locked and limited conversation to collaborators May 4, 2024
@joperezr
Copy link
Member

[for tracking] This was a backport of #3235

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants