-
Notifications
You must be signed in to change notification settings - Fork 457
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
Add command annotations and wire up #5538
Conversation
src/Aspire.Hosting/ApplicationModel/ResourceCommandAnnotation.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting/Dashboard/CommandsConfigurationExtensions.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting/Dashboard/CommandsConfigurationExtensions.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting/Dashboard/CommandsConfigurationExtensions.cs
Outdated
Show resolved
Hide resolved
Looking good overall. This was pretty close to what I was envisaging. Left a few comments to discuss. |
src/Aspire.Hosting/ApplicationModel/ResourceCommandAnnotation.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting/Dashboard/CommandsConfigurationExtensions.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs
Outdated
Show resolved
Hide resolved
Made a bunch of changes and applied PR feedback. I think this is close to being good. (Ignore lack of API xml comments and the fact that start/stop/restart don't actually do anything yet 😄) |
src/Aspire.Hosting/Dashboard/CommandsConfigurationExtensions.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs
Outdated
Show resolved
Hide resolved
c1cfac8
to
45b8706
Compare
8f49cda
to
9996ae5
Compare
src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs
Outdated
Show resolved
Hide resolved
await executor.StopResourceAsync(context.ResourceName, context.CancellationToken).ConfigureAwait(false); | ||
await executor.StartResourceAsync(context.ResourceName, context.CancellationToken).ConfigureAwait(false); |
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.
Does this work? Start/Stop in quick succession?
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.
I talked with @karolz-ms about restarting containers, and it sounds like that work might not get done for 9 because wait for is prioritized. Therefor to restart both containers and executables from the app host, we'll delete the resource and then recreate it.
That means the StopResourceAsync
may or may not be needed here. Do we want to gracefully stop a resource before it starting it up again? Or do we just delete and recreate it? Delete+create would be faster.
e4cb2b8
to
5c17fb3
Compare
Here is the problem with what you're saying: the update method is only triggered when the resource snapshot updates. If you need to talk to the database to figure out the state, you can only do that if something updates the resource snapshot. The resource might be in a happy Running state since it starts up and the command state methods are never called. For example, there is a command to perform an EF migration. It has an update state method that queries the DB to see if the command is enabled or disabled. The command could be enabled and some other tool could perform the migration - so the command should be disabled - but the command stays enabled because the resource snapshot doesn't update. The way this could work instead is when the resource starts there is a background task that queries the database (or file, or web service, etc) every 10 seconds to figure out whether the command is valid or not. That task uses
This isn't from polling. The methods are re-evaluated when the resource state updates, which is pushed from the notification service. A resource starting up or shutting down has half a dozen rapid resource state updates as the state and endpoints change. If there is a command state update method that does something like query a web service, and the network is down, then it could take seconds to time out. Resource updates in Asoure are now going to be slowed down while waiting for that timeout, multipled by the number of times it is called. |
3987b04
to
d7fefb8
Compare
e9babf4
to
97ac713
Compare
@@ -2,12 +2,12 @@ | |||
@using Aspire.Dashboard.Model | |||
@using Microsoft.FluentUI.AspNetCore.Components | |||
|
|||
@foreach (var highlightedCommand in Commands.Where(c => c.IsHighlighted)) | |||
@foreach (var highlightedCommand in Commands.Where(c => c.IsHighlighted && c.State != CommandViewModelState.Hidden)) |
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.
Should there be a maximum number of highlighted commands? Or rather only the first N highlighted commands?
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.
Maybe. It's easy to change if necessary.
@@ -49,7 +49,7 @@ protected override void OnParametersSet() | |||
OnClick = OnConsoleLogs.InvokeAsync | |||
}); | |||
|
|||
var menuCommands = Commands.Where(c => !c.IsHighlighted).ToList(); | |||
var menuCommands = Commands.Where(c => !c.IsHighlighted && c.State != CommandViewModelState.Hidden).ToList(); |
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.
Should the context menu show all commands regardless of whether they are highlighted or not?
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.
Dunno. It's easy to change.
@@ -33,7 +33,7 @@ | |||
Class="severity-icon" /> | |||
} | |||
} | |||
else if (Resource.IsStartingOrBuildingOrWaiting()) | |||
else if (Resource.IsUnusableTransitoryState()) |
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.
It's a race with #5770 :)
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.
LGTM. Some minor points of feedback that can be follow up PRs if necessary.
3506e18
to
63a9a90
Compare
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
if (!resourceNotFound) | ||
{ | ||
// Limit polling to 5 attempts to avoid hanging with an infinite loop. | ||
for (var i = 0; i < 5; i++) |
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.
Why don't you use polly 😄
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.
I've used polly zero times and I've used for loops a million times 😋
Next time I make start/stop/restart changes in this area I'll try it out.
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.
It's in this same file
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.
Since the build is failing anyway, changed to polly.
Observation: I haven't used polly before, but should the polly options and pipelines be cached? They're created every run right now. Might not be necessary.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Fixes #1410 (cleaned up test while I was here)
Fixes #295
Changes in PR:
Checklist
<remarks />
and<code />
elements on your triple slash comments?Microsoft Reviewers: Open in CodeFlow