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

Allow dashboard to run without resource service #1815

Merged
merged 9 commits into from
Jan 25, 2024

Conversation

drewnoakes
Copy link
Member

@drewnoakes drewnoakes commented Jan 24, 2024

(Replaces #1795 which closed when we merged the feature branch.)

Relates to #1556

With the dashboard running OOP, it is configured with the resource server endpoint via the DOTNET_DASHBOARD_GRPC_ENDPOINT_URL environment variable.

The dashboard can actually perform useful work even without this connection, however it requires some code changes to support this.

In this PR, if the environment variable is not defined, then IDashboardClient.IsEnabled will be false, and some code paths become inactive based off the flag.

To get tests passing, we introduce an abstraction for environment variables so we can inject the values we need.

The navigation tree will not display the "Resources" or "Console logs" items when no resource service endpoint is available:

image


Pending work:

  • On load the page currently routes to / which shows an empty Resources list. Route somewhere else.
  • Update dashboard's README
Microsoft Reviewers: Open in CodeFlow

With the dashboard running OOP, it is configured with the resource server endpoint via an environment variable.

The dashboard can actually perform useful work even without this connection, however it requires some code changes to support this.

In this change, if the environment variable is not defined, then `IDashboardClient.IsEnabled` will be false, and some code paths become inactive based off the flag.

To get tests passing, we introduce an abstraction for environment variables so we can inject the values we need.

The navigation tree will not display the "Resources" or "Console logs" items when no resource service endpoint is available.

---

Squashed from several other commits:

Add singular overload of EnvironmentUtil.GetAddressUris

And tidy up some code that parsed `DOTNET_DASHBOARD_GRPC_ENDPOINT_URL`. Change that code to only support a single URI for that purpose, as it only makes one connection.

DashboardClient is disabled when no dashboard endpoint

When the `DOTNET_DASHBOARD_GRPC_ENDPOINT_URL` variable is not in the dashboard's environment, the `DashboardClient` disables itself. In this state, it will throw when invoked, though you may query the `IsEnabled` property safely before making other calls.

Add IEnvironmentVariables abstraction for unit testing

Makes it possible to unit test environment variables.

Make init properties

Remove redundant null suppression

Hide navigation items when resource service unavailable

Hides the "Resources" and "Console logs" navigation menu items whenever the `DashboardClient` is not enabled (due to `DOTNET_DASHBOARD_GRPC_ENDPOINT_URL` not being available).

Check if IDashboardClient is enabled before calling it
@JamesNK
Copy link
Member

JamesNK commented Jan 24, 2024

The title should have a value when there is no resource server. "Aspire dashboard"?

An option to set it via argument/env var would be useful, but no one has asked for that yet.

@drewnoakes
Copy link
Member Author

The title should have a value when there is no resource server. "Aspire dashboard"?

An option to set it via argument/env var would be useful, but no one has asked for that yet.

I like this idea! Added:

    string IDashboardClient.ApplicationName
    {
        get => _applicationName
            ?? _environmentVariables.GetString("DOTNET_DASHBOARD_APPLICATION_NAME")
            ?? "Aspire";
    }

@drewnoakes
Copy link
Member Author

@JamesNK PTAL. I'd like to get this merged in so there's more chance it's included in the next round of testing.

@drewnoakes drewnoakes enabled auto-merge (squash) January 25, 2024 02:42
@drewnoakes drewnoakes merged commit 3cd891a into dotnet:main Jan 25, 2024
8 checks passed
@drewnoakes drewnoakes deleted the disconnected-client-2 branch January 25, 2024 03:10
@github-actions github-actions bot locked and limited conversation to collaborators Apr 25, 2024
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.

3 participants