Skip to content

Commit 4ebda28

Browse files
github-actions[bot]Copilotdavidfowlmitchdenny
authored
[release/9.4] Remove duplicate startup logging from DashboardLifecycleHook (#10692)
* Initial plan * Remove duplicate startup logging from DashboardLifecycleHook Co-authored-by: davidfowl <[email protected]> * Restore ResourceReadyEvent handler as requested by @davidfowl Co-authored-by: davidfowl <[email protected]> * Remove duplicate logging from ConfigureEnvironmentVariables method Co-authored-by: davidfowl <[email protected]> * Update src/Aspire.Hosting/Dashboard/DashboardLifecycleHook.cs * Dashboard URL parsing can happen out of sequence. * Apply suggestions from code review * Revert "Apply suggestions from code review" This reverts commit cfd0231. * Enhance StartAppHostAsync to optionally wait for dashboard URL during startup --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: davidfowl <[email protected]> Co-authored-by: David Fowler <[email protected]> Co-authored-by: Mitch Denny <[email protected]>
1 parent 6b60a26 commit 4ebda28

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

src/Aspire.Hosting/Dashboard/DashboardLifecycleHook.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -344,19 +344,6 @@ internal async Task ConfigureEnvironmentVariables(EnvironmentCallbackContext con
344344
context.EnvironmentVariables[DashboardConfigNames.DebugSessionTelemetryOptOutName.EnvVarName] = optOutValue;
345345
}
346346

347-
if (!StringUtils.TryGetUriFromDelimitedString(options.DashboardUrl, ";", out var firstDashboardUrl))
348-
{
349-
return;
350-
}
351-
352-
var dashboardUrl = codespaceUrlRewriter.RewriteUrl(firstDashboardUrl.ToString());
353-
354-
distributedApplicationLogger.LogInformation("Now listening on: {DashboardUrl}", dashboardUrl.TrimEnd('/'));
355-
356-
if (!string.IsNullOrEmpty(browserToken))
357-
{
358-
LoggingHelpers.WriteDashboardUrl(distributedApplicationLogger, dashboardUrl, browserToken, isContainer: false);
359-
}
360347
}
361348

362349
private static void PopulateDashboardUrls(EnvironmentCallbackContext context)

tests/Aspire.EndToEnd.Tests/IntegrationServicesFixture.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ public async ValueTask InitializeAsync()
7878
{
7979
extraArgs += $"--skip-resources {skipArg}";
8080
}
81-
await Project.StartAppHostAsync([extraArgs]);
81+
82+
var waitForDashboard = !_resourcesToSkip.HasFlag(TestResourceNames.dashboard);
83+
await Project.StartAppHostAsync([extraArgs], waitForDashboardUrl: waitForDashboard);
8284

8385
foreach (var project in Projects.Values)
8486
{

tests/Shared/TemplatesTesting/AspireProject.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public static async Task<AspireProject> CreateNewTemplateProjectAsync(
158158
return project;
159159
}
160160

161-
public async Task StartAppHostAsync(string[]? extraArgs = default, Action<ProcessStartInfo>? configureProcess = null, bool noBuild = true, CancellationToken token = default)
161+
public async Task StartAppHostAsync(string[]? extraArgs = default, Action<ProcessStartInfo>? configureProcess = null, bool noBuild = true, bool waitForDashboardUrl = true, CancellationToken token = default)
162162
{
163163
if (IsRunning)
164164
{
@@ -169,6 +169,7 @@ public async Task StartAppHostAsync(string[]? extraArgs = default, Action<Proces
169169
var output = new StringBuilder();
170170
var projectsParsed = new TaskCompletionSource();
171171
var appRunning = new TaskCompletionSource();
172+
var dashboardUrlParsed = new TaskCompletionSource();
172173
var stdoutComplete = new TaskCompletionSource();
173174
var stderrComplete = new TaskCompletionSource();
174175
AppExited = new();
@@ -213,6 +214,7 @@ public async Task StartAppHostAsync(string[]? extraArgs = default, Action<Proces
213214
if (m.Success)
214215
{
215216
DashboardUrl = m.Groups["url"].Value;
217+
dashboardUrlParsed.SetResult();
216218
}
217219

218220
if (line?.StartsWith("$ENDPOINTS: ") == true)
@@ -263,7 +265,13 @@ public async Task StartAppHostAsync(string[]? extraArgs = default, Action<Proces
263265
AppHostProcess.BeginOutputReadLine();
264266
AppHostProcess.BeginErrorReadLine();
265267

266-
var successfulStartupTask = Task.WhenAll(appRunning.Task, projectsParsed.Task);
268+
var tasksToWaitFor = new List<Task> { appRunning.Task, projectsParsed.Task };
269+
if (waitForDashboardUrl)
270+
{
271+
tasksToWaitFor.Add(dashboardUrlParsed.Task);
272+
}
273+
274+
var successfulStartupTask = Task.WhenAll(tasksToWaitFor);
267275
var startupTimeoutTask = Task.Delay(TimeSpan.FromSeconds(AppStartupWaitTimeoutSecs), token);
268276

269277
string outputMessage;

0 commit comments

Comments
 (0)