fix(docker): enhance error handling and user feedback for Docker service unavailability

This commit is contained in:
GitHub Actions
2026-01-10 00:08:25 +00:00
parent 311c75abaa
commit db0ab55373
10 changed files with 444 additions and 36 deletions

View File

@@ -71,12 +71,15 @@ func (h *DockerHandler) ListContainers(c *gin.Context) {
if err != nil {
var unavailableErr *services.DockerUnavailableError
if errors.As(err, &unavailableErr) {
log.WithFields(map[string]any{"server_id": serverID}).WithError(err).Warn("docker unavailable")
c.JSON(http.StatusServiceUnavailable, gin.H{"error": "Docker daemon unavailable"})
log.WithFields(map[string]any{"server_id": serverID, "host": host}).WithError(err).Warn("docker unavailable")
c.JSON(http.StatusServiceUnavailable, gin.H{
"error": "Docker daemon unavailable",
"details": "Cannot connect to Docker. Please ensure Docker is running and the socket is accessible (e.g., /var/run/docker.sock is mounted).",
})
return
}
log.WithFields(map[string]any{"server_id": serverID}).WithError(err).Error("failed to list containers")
log.WithFields(map[string]any{"server_id": serverID, "host": host}).WithError(err).Error("failed to list containers")
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to list containers"})
return
}