healthcheck: do not interpret exit code 2 as "starting"

Instead reserve exit code 2 to be future proof, document that it should
not be used. Implementation-wise, it is considered as unhealthy, but
users should not rely on this as it may change in the future.

Signed-off-by: Tibor Vass <tibor@docker.com>
Upstream-commit: 91e9f3831330c63f8351b9fc3f7c31b3229505be
Component: engine
This commit is contained in:
Tibor Vass
2016-07-20 10:50:04 -07:00
parent 7ebd4850f0
commit 11cd397072
3 changed files with 2 additions and 24 deletions

View File

@ -41,7 +41,6 @@ const (
exitStatusHealthy = 0 // Container is healthy
exitStatusUnhealthy = 1 // Container is unhealthy
exitStatusStarting = 2 // Container needs more time to start
)
// probe implementations know how to run a particular type of probe.
@ -127,12 +126,10 @@ func handleProbeResult(d *Daemon, c *container.Container, result *types.Healthch
if result.ExitCode == exitStatusHealthy {
h.FailingStreak = 0
h.Status = types.Healthy
} else if result.ExitCode == exitStatusStarting && c.State.Health.Status == types.Starting {
// The container is not ready yet. Remain in the starting state.
} else {
// Failure (including invalid exit code)
h.FailingStreak++
if c.State.Health.FailingStreak >= retries {
if h.FailingStreak >= retries {
h.Status = types.Unhealthy
}
// Else we're starting or healthy. Stay in that state.

View File

@ -94,22 +94,6 @@ func TestHealthStates(t *testing.T) {
handleResult(c.State.StartedAt.Add(3*time.Second), 1)
expect("health_status: unhealthy")
// starting -> starting -> starting ->
// healthy -> starting (invalid transition)
reset(c)
handleResult(c.State.StartedAt.Add(20*time.Second), 2)
handleResult(c.State.StartedAt.Add(40*time.Second), 2)
if c.State.Health.Status != types.Starting {
t.Errorf("Expecting starting, but got %#v\n", c.State.Health.Status)
}
handleResult(c.State.StartedAt.Add(50*time.Second), 0)
expect("health_status: healthy")
handleResult(c.State.StartedAt.Add(60*time.Second), 2)
expect("health_status: unhealthy")
// Test retries
reset(c)