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>
(cherry picked from commit 91e9f3831330c63f8351b9fc3f7c31b3229505be)
Signed-off-by: Tibor Vass <tibor@docker.com>
| ... | ... |
@@ -41,7 +41,6 @@ const ( |
| 41 | 41 |
|
| 42 | 42 |
exitStatusHealthy = 0 // Container is healthy |
| 43 | 43 |
exitStatusUnhealthy = 1 // Container is unhealthy |
| 44 |
- exitStatusStarting = 2 // Container needs more time to start |
|
| 45 | 44 |
) |
| 46 | 45 |
|
| 47 | 46 |
// 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 |
| 127 | 127 |
if result.ExitCode == exitStatusHealthy {
|
| 128 | 128 |
h.FailingStreak = 0 |
| 129 | 129 |
h.Status = types.Healthy |
| 130 |
- } else if result.ExitCode == exitStatusStarting && c.State.Health.Status == types.Starting {
|
|
| 131 |
- // The container is not ready yet. Remain in the starting state. |
|
| 132 | 130 |
} else {
|
| 133 | 131 |
// Failure (including invalid exit code) |
| 134 | 132 |
h.FailingStreak++ |
| 135 |
- if c.State.Health.FailingStreak >= retries {
|
|
| 133 |
+ if h.FailingStreak >= retries {
|
|
| 136 | 134 |
h.Status = types.Unhealthy |
| 137 | 135 |
} |
| 138 | 136 |
// Else we're starting or healthy. Stay in that state. |
| ... | ... |
@@ -94,22 +94,6 @@ func TestHealthStates(t *testing.T) {
|
| 94 | 94 |
handleResult(c.State.StartedAt.Add(3*time.Second), 1) |
| 95 | 95 |
expect("health_status: unhealthy")
|
| 96 | 96 |
|
| 97 |
- // starting -> starting -> starting -> |
|
| 98 |
- // healthy -> starting (invalid transition) |
|
| 99 |
- |
|
| 100 |
- reset(c) |
|
| 101 |
- |
|
| 102 |
- handleResult(c.State.StartedAt.Add(20*time.Second), 2) |
|
| 103 |
- handleResult(c.State.StartedAt.Add(40*time.Second), 2) |
|
| 104 |
- if c.State.Health.Status != types.Starting {
|
|
| 105 |
- t.Errorf("Expecting starting, but got %#v\n", c.State.Health.Status)
|
|
| 106 |
- } |
|
| 107 |
- |
|
| 108 |
- handleResult(c.State.StartedAt.Add(50*time.Second), 0) |
|
| 109 |
- expect("health_status: healthy")
|
|
| 110 |
- handleResult(c.State.StartedAt.Add(60*time.Second), 2) |
|
| 111 |
- expect("health_status: unhealthy")
|
|
| 112 |
- |
|
| 113 | 97 |
// Test retries |
| 114 | 98 |
|
| 115 | 99 |
reset(c) |
| ... | ... |
@@ -1524,10 +1524,7 @@ The possible values are: |
| 1524 | 1524 |
|
| 1525 | 1525 |
- 0: success - the container is healthy and ready for use |
| 1526 | 1526 |
- 1: unhealthy - the container is not working correctly |
| 1527 |
-- 2: starting - the container is not ready for use yet, but is working correctly |
|
| 1528 |
- |
|
| 1529 |
-If the probe returns 2 ("starting") when the container has already moved out of the
|
|
| 1530 |
-"starting" state then it is treated as "unhealthy" instead. |
|
| 1527 |
+- 2: reserved - do not use this exit code |
|
| 1531 | 1528 |
|
| 1532 | 1529 |
For example, to check every five minutes or so that a web-server is able to |
| 1533 | 1530 |
serve the site's main page within three seconds: |