Skip to content

Improve the experience when docker isn't running#6135

Merged
davidfowl merged 2 commits intomainfrom
davidfowl/start-when-docker-fails
Oct 7, 2024
Merged

Improve the experience when docker isn't running#6135
davidfowl merged 2 commits intomainfrom
davidfowl/start-when-docker-fails

Conversation

@davidfowl
Copy link
Copy Markdown
Contributor

@davidfowl davidfowl commented Oct 5, 2024

Description

  • When the container runtime isn't running, log a critical error but continue running and sending requests to dcp. DCP will wait for the container runtime to be healthy (started) and will run the containers.

Fixes #5533

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
      • Link to aspire-docs issue:
    • No
Microsoft Reviewers: Open in CodeFlow

- When the container runtime isn't running, log a critical error but continue running and sending requests to dcp. DCP will wait for the container runtime to be healthy (started) and will run the containers.
@davidfowl
Copy link
Copy Markdown
Contributor Author

davidfowl commented Oct 5, 2024

When you launch the app host, this is what it says:

image

This is what the dashboard looks like when the container runtime isn't running.

image

@danegsta I think dcp should set the state of these containers to something that reflects that. I can do it in the apphost but it feels like the source of truth for what the container state is should be dcp. We could use a new state "Error" or "Container runtime unhealthy" etc.

We show logs in each of the containers that show the error message from DCP:

image

Here's what it looks like when you run docker:

start-docker-2.mp4

@danegsta
Copy link
Copy Markdown
Member

danegsta commented Oct 5, 2024

First thought is that we could add something like MissingRequirement as the new state and a status property for the specific related error to make it easier to surface in the Dashboard.

@davidfowl
Copy link
Copy Markdown
Contributor Author

First thought is that we could add something like MissingRequirement as the new state and a status property for the specific related error to make it easier to surface in the Dashboard.

I think we should do something like that. But we should make it specific to the actual state instead of a generic MissingRequirement state (unless there's some other way to show the specific reason).

@davidfowl davidfowl changed the title Improve the experience when docker isnt' running Improve the experience when docker isn't running Oct 6, 2024
@mitchdenny
Copy link
Copy Markdown
Member

mitchdenny commented Oct 7, 2024

I think that @danegsta is right about having a MissingRequirements state. The reason is that this PR will need to include an update to KnownResourceStates.TerminalStates to account for getting into this state. This is used by WaitForCompletion(...) (ultimately).

Spoke to @davidfowl behind the scenes on a bit more of the intent here. We don't want DCP to set a terminal state because we want folks to be able to start their Docker instance behind the scenes and have it suddenly come to life without having to restart the apphost.

Given this I'm happy with this PR.

@davidfowl davidfowl marked this pull request as ready for review October 7, 2024 02:45
@JamesNK
Copy link
Copy Markdown
Member

JamesNK commented Oct 7, 2024

This is what I see in the UI:

image

And resources page:

image

And this is in the console logs:

image

Overall I like it.

Suggestions for improvement:

  1. There is duplication between error messages printed to app host console and resource console. Maybe share code? I like that the app host console includes the name of the runtime, and I like that the console logs includes the error message from DCP. One set of code that does both?

  2. Putting myself in the shoes of an Aspire beginner, I don't know what unhealthy means. Do I need to reinstall Docker? We could look at the error message from DCP and if there is matching content, log in the UI that the container runtime isn't running.

    Get "http://%2F%2F.%2Fpipe%2FdockerDesktopLinuxEngine/v1.47/containers/json?limit=1";: open //./pipe/dockerDesktopLinuxEngine: The system cannot find the file specified.

    Look for "open //./pipe/dockerDesktopLinuxEngine"? It might be better than "The system cannot find the file specified." which could be localized.
    Would need to do something similar for podman which no doubt has a different address.

    If this is best done with DCP changes, a simple improvement for 9.0 could to always suggest checking the container runtime is running if it's unhealthy.

  3. Unknown should be a more specific error state and have an error icon. I think that needs DCP changes to work smoothy so it could be a 9.x improvement.

- Share code that logs errors about the container runtime.
- Improve the error message for docker and podman.
@davidfowl
Copy link
Copy Markdown
Contributor Author

I moved the code to a shared location, and I improved the error message as much as I could (using chatgpt 😄 )

@davidfowl davidfowl merged commit 1f28351 into main Oct 7, 2024
@davidfowl davidfowl deleted the davidfowl/start-when-docker-fails branch October 7, 2024 09:21
@maddymontaquila
Copy link
Copy Markdown
Contributor

yessssss 🔥

@davidfowl
Copy link
Copy Markdown
Contributor Author

/backport to release/9.0-rc1

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 7, 2024

Started backporting to release/9.0-rc1: https://github.com/dotnet/aspire/actions/runs/11222760501

@github-actions github-actions bot locked and limited conversation to collaborators Nov 7, 2024
@github-actions github-actions bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Mar 10, 2025
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Throw a friendly error from Aspire if Docker isn't running

5 participants