From 3982f039a2a67159be894443455204a381b82137 Mon Sep 17 00:00:00 2001 From: Dong Chen Date: Fri, 15 Jul 2016 11:05:42 -0700 Subject: [PATCH] Add healthcheck info to CLI. Signed-off-by: Dong Chen --- cluster/container.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cluster/container.go b/cluster/container.go index 467d777c51..c745008807 100644 --- a/cluster/container.go +++ b/cluster/container.go @@ -54,6 +54,19 @@ func FullStateString(state *types.ContainerState) string { if state.Restarting { return fmt.Sprintf("Restarting (%d) %s ago", state.ExitCode, units.HumanDuration(time.Now().UTC().Sub(finishedAt))) } + // Container is Up. Add Health check info when healthcheck is defined. + healthText := "" + if h := state.Health; h != nil { + switch h.Status { + case types.Starting: + healthText = "health: starting" + default: // Healthy and Unhealthy are clear on their own + healthText = h.Status + } + } + if len(healthText) > 0 { + return fmt.Sprintf("Up %s (%s)", units.HumanDuration(time.Now().UTC().Sub(startedAt)), healthText) + } return fmt.Sprintf("Up %s", units.HumanDuration(time.Now().UTC().Sub(startedAt))) }