dotnet / dotnet-docker

Docker images for .NET and the .NET Tools.
https://hub.docker.com/_/microsoft-dotnet
MIT License
4.49k stars 1.94k forks source link

Aspire Dashboard image fails to start #5164

Closed lbussell closed 9 months ago

lbussell commented 9 months ago

The image mcr.microsoft.com/dotnet/nightly/aspire-dashboard:8.0-preview fails to start.

The image digest specifically is sha256:b62c4d1fd63d61dc9abcdd220ca047c5049f9a74fc9841096928f72fcc4a94f7

Steps to Reproduce

  1. docker pull mcr.microsoft.com/dotnet/nightly/aspire-dashboard:8.0-preview
  2. docker run mcr.microsoft.com/dotnet/nightly/aspire-dashboard:8.0-preview
  3. Observe the following error:
Unhandled exception. System.InvalidOperationException: Error parsing URIs from environment variable 'ASPNETCORE_URLS'.
 ---> System.UriFormatException: Invalid URI: The hostname could not be parsed.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
   at System.Uri..ctor(String uriString, UriKind uriKind)
   at Aspire.IEnvironmentVariablesExtensions.<>c.<GetUris>b__3_0(String url) in /_/src/Aspire.Hosting/Utils/IEnvironmentVariables.cs:line 146
   at System.Linq.Enumerable.SelectArrayIterator`2.Fill(ReadOnlySpan`1 source, Span`1 destination, Func`2 func)
   at System.Linq.Enumerable.SelectArrayIterator`2.ToArray()
   at Aspire.IEnvironmentVariablesExtensions.GetUris(IEnvironmentVariables env, String variableName, Uri defaultValue) in /_/src/Aspire.Hosting/Utils/IEnvironmentVariables.cs:line 144
   --- End of inner exception stack trace ---
   at Aspire.IEnvironmentVariablesExtensions.GetUris(IEnvironmentVariables env, String variableName, Uri defaultValue) in /_/src/Aspire.Hosting/Utils/IEnvironmentVariables.cs:line 152
   at Aspire.Dashboard.DashboardWebApplication..ctor() in /_/src/Aspire.Dashboard/DashboardWebApplication.cs:line 36
   at Program.<Main>$(String[] args) in /_/src/Aspire.Dashboard/Program.cs:line 7
dotnet-issue-labeler[bot] commented 9 months ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

lbussell commented 9 months ago

The following environment variables are the cause of the issue:

DOTNET_DASHBOARD_OTLP_ENDPOINT_URL=http://*:18889
ASPNETCORE_URLS=http://*:18888

I also tried the http://+:18889 format and had the same error.

I found two formats that do work in this scenario - http://localhost:18888 and http://0.0.0.0:18888. So a workaround to this issue would be to add these arguments to your docker run command: -e ASPNETCORE_URLS=http://localhost:18888 -e DOTNET_DASHBOARD_OTLP_ENDPOINT_URL=http://localhost:18889.

I haven't seen the + or * URI formats fail in other ASP.NET Core applications. Is this something specific to Aspire or an issue with ASP.NET?

/cc @joperezr @davidfowl

davidfowl commented 9 months ago

Yea lets use 0.0.0.0 for now. I'll make sure we fix this on the aspire side.

baronfel commented 9 months ago

So I'm using the new, fixed environment variable version of the dashboard (thanks for the quick turnaround!) and I'm having trouble getting the dashboard to start. Here's the docker command I'm using right now:

> docker run --rm -it -d -p 18888:18888 -p 18889:18889 mcr.microsoft.com/dotnet/nightly/aspire-dashboard:8.0-preview aspire-dashboard

So I'm mapping ports for HTTP and OTLP, then going to localhost:18888 in my browser, which renders a white screen. The network pane shows a POST to disconnect:

image

And the console is talking about an unhandled exception for the blazor circuit:

image

Are other folks seeing the same things?

lbussell commented 9 months ago

I believe this is a known issue - currently the container needs some extra environment variables in order for the portal to render. Apparently this is fixed in the newer versions of the dashboard - we will get new versions out after https://github.com/dotnet/dotnet-docker/issues/5154 is done (or we could get an updated version out by hand while I work on that). @joperezr can comment more on this.

baronfel commented 9 months ago

Ok, great! Glad this is a known thing :)

davidfowl commented 9 months ago

Not sure.

cc @drewnoakes @kvenkatrajan

JamesNK commented 9 months ago

The error from the circuit error should appear in the container's console output. Do you have that available?

davidfowl commented 9 months ago

Not sure this is a known issue. It seems like it doesn't work at all.

2024-02-07 00:05:46 info: Aspire.Dashboard[0]
2024-02-07 00:05:46       Now listening on: http://0.0.0.0:18888
2024-02-07 00:05:46 info: Aspire.Dashboard[0]
2024-02-07 00:05:46       OTLP server running at: http://0.0.0.0:18889
2024-02-07 00:05:46 warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
2024-02-07 00:05:46       Storing keys in a directory '/home/app/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed. For more information go to https://aka.ms/aspnet/dataprotectionwarning
2024-02-07 00:05:46 warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
2024-02-07 00:05:46       No XML encryptor configured. Key {ffe79638-acb8-41b8-9fb9-7b7e73e9d475} may be persisted to storage in unencrypted form.
2024-02-07 00:06:01 info: Aspire.Dashboard.Model.DashboardClient[0]
2024-02-07 00:06:01       DOTNET_RESOURCE_SERVICE_ENDPOINT_URL is not specified. Dashboard client services are unavailable.
2024-02-07 00:06:01 warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]
2024-02-07 00:06:01       Unhandled exception rendering component: DashboardClient is disabled. Check the IsEnabled property before calling this.
2024-02-07 00:06:01       System.InvalidOperationException: DashboardClient is disabled. Check the IsEnabled property before calling this.
2024-02-07 00:06:01          at Aspire.Dashboard.Model.DashboardClient.EnsureInitialized() in /_/src/Aspire.Dashboard/Model/DashboardClient.cs:line 135
2024-02-07 00:06:01          at Aspire.Dashboard.Model.DashboardClient.Aspire.Dashboard.Model.IDashboardClient.get_WhenConnected() in /_/src/Aspire.Dashboard/Model/DashboardClient.cs:line 301
2024-02-07 00:06:01          at Aspire.Dashboard.Components.ApplicationName.OnInitializedAsync() in /_/src/Aspire.Dashboard/Components/Controls/ApplicationName.razor.cs:line 29
2024-02-07 00:06:01          at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
2024-02-07 00:06:01 fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
2024-02-07 00:06:01       Unhandled exception in circuit 'oznl3xD7hXdCm4v2UQYLRNEP-DgI-BSROO-PucH1KZ0'.
2024-02-07 00:06:01       System.InvalidOperationException: DashboardClient is disabled. Check the IsEnabled property before calling this.
2024-02-07 00:06:01          at Aspire.Dashboard.Model.DashboardClient.EnsureInitialized() in /_/src/Aspire.Dashboard/Model/DashboardClient.cs:line 135
2024-02-07 00:06:01          at Aspire.Dashboard.Model.DashboardClient.Aspire.Dashboard.Model.IDashboardClient.get_WhenConnected() in /_/src/Aspire.Dashboard/Model/DashboardClient.cs:line 301
2024-02-07 00:06:01          at Aspire.Dashboard.Components.ApplicationName.OnInitializedAsync() in /_/src/Aspire.Dashboard/Components/Controls/ApplicationName.razor.cs:line 29
2024-02-07 00:06:01          at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
2024-02-07 00:06:01 warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]
2024-02-07 00:06:01       Unhandled exception rendering component: Cannot access a disposed object.
2024-02-07 00:06:01       System.ObjectDisposedException: Cannot access a disposed object.
2024-02-07 00:06:01          at Microsoft.AspNetCore.Components.RenderTree.ArrayBuilder`1.GrowBuffer(Int32 desiredCapacity)
2024-02-07 00:06:01          at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex)
2024-02-07 00:06:01          at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
2024-02-07 00:06:01          at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer renderer, RenderBatchBuilder batchBuilder, Int32 componentId, ArrayRange`1 oldTree, ArrayRange`1 newTree)
2024-02-07 00:06:01          at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)
2024-02-07 00:06:01          at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()
2024-02-07 00:06:01 fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
2024-02-07 00:06:01       Unhandled exception in circuit 'oznl3xD7hXdCm4v2UQYLRNEP-DgI-BSROO-PucH1KZ0'.
2024-02-07 00:06:01       System.ObjectDisposedException: Cannot access a disposed object.
2024-02-07 00:06:01          at Microsoft.AspNetCore.Components.RenderTree.ArrayBuilder`1.GrowBuffer(Int32 desiredCapacity)
2024-02-07 00:06:01          at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex)
2024-02-07 00:06:01          at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
2024-02-07 00:06:01          at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer renderer, RenderBatchBuilder batchBuilder, Int32 componentId, ArrayRange`1 oldTree, ArrayRange`1 newTree)
2024-02-07 00:06:01          at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)
2024-02-07 00:06:01          at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()
davidfowl commented 9 months ago

I saw a similar thing when running from the command line outside of the host:

https://github.com/dotnet/aspire/issues/1556#issuecomment-1916189785

lbussell commented 9 months ago

[Triage] The fundamental problem described in the issue body has been worked around by https://github.com/dotnet/dotnet-docker/pull/5165. We should open new issues for any additional problems that occur after the dashboard process has started. Additionally I will open an issue to remove the workaround introduced in https://github.com/dotnet/dotnet-docker/pull/5165.

davidfowl commented 9 months ago

The issue is opened (and root caused) on the aspire repo.