Harden Docker container runtime health check#10402
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR strengthens the container runtime health check by verifying that the Docker daemon is running before checking Docker Buildx availability.
- Adds
CheckDockerDaemonAsyncto probe the Docker daemon viadocker container ls -n 1 - Adds
CheckDockerBuildxAsyncto validate that Buildx is installed and functioning - Updates
CheckIfRunningAsyncto chain both checks sequentially
Comments suppressed due to low confidence (1)
src/Aspire.Hosting/Publishing/DockerContainerRuntime.cs:134
- Add unit tests for the new
CheckDockerDaemonAsyncandCheckDockerBuildxAsyncmethods, covering both successful and failure paths to ensure the health check logic is fully validated.
public async Task<bool> CheckIfRunningAsync(CancellationToken cancellationToken)
| OnErrorData = error => | ||
| { | ||
| logger.LogInformation("docker buildx version (stderr): {Error}", error); | ||
| logger.LogInformation("docker container ls (stderr): {Error}", error); |
There was a problem hiding this comment.
[nitpick] Consider using LogWarning or LogError for stderr output to better reflect that this data represents an error stream rather than informational messages.
| logger.LogInformation("docker container ls (stderr): {Error}", error); | |
| logger.LogWarning("docker container ls (stderr): {Error}", error); |
| OnOutputData = output => | ||
| { | ||
| logger.LogInformation("docker buildx version (stdout): {Output}", output); | ||
| logger.LogInformation("docker container ls (stdout): {Output}", output); | ||
| }, | ||
| OnErrorData = error => | ||
| { | ||
| logger.LogInformation("docker buildx version (stderr): {Error}", error); | ||
| logger.LogInformation("docker container ls (stderr): {Error}", error); | ||
| }, |
There was a problem hiding this comment.
[nitpick] The OnOutputData and OnErrorData logging closures are duplicated in both health-check methods; consider extracting a shared helper to reduce duplication and improve maintainability.
| OnOutputData = output => | |
| { | |
| logger.LogInformation("docker buildx version (stdout): {Output}", output); | |
| logger.LogInformation("docker container ls (stdout): {Output}", output); | |
| }, | |
| OnErrorData = error => | |
| { | |
| logger.LogInformation("docker buildx version (stderr): {Error}", error); | |
| logger.LogInformation("docker container ls (stderr): {Error}", error); | |
| }, | |
| OnOutputData = output => LogProcessOutput("stdout", output), | |
| OnErrorData = error => LogProcessOutput("stderr", error), |
|
Do the same for podman? |
|
/backport to release/9.4 |
|
Started backporting to release/9.4: https://github.com/dotnet/aspire/actions/runs/16283710455 |
Closes #10391.