Browse code

Merge pull request #23232 from thaJeztah/update-default-retries

Healthcheck: set default retries to 3

Vincent Demeester authored on 2016/06/04 14:50:04
Showing 4 changed files
... ...
@@ -2,7 +2,7 @@ FROM debian
2 2
 ADD check.sh main.sh /app/
3 3
 CMD /app/main.sh
4 4
 HEALTHCHECK
5
-HEALTHCHECK --interval=5s --timeout=3s --retries=1 \
5
+HEALTHCHECK --interval=5s --timeout=3s --retries=3 \
6 6
   CMD /app/check.sh --quiet
7 7
 HEALTHCHECK CMD
8 8
 HEALTHCHECK   CMD   a b
... ...
@@ -2,7 +2,7 @@
2 2
 (add "check.sh" "main.sh" "/app/")
3 3
 (cmd "/app/main.sh")
4 4
 (healthcheck)
5
-(healthcheck ["--interval=5s" "--timeout=3s" "--retries=1"] "CMD" "/app/check.sh --quiet")
5
+(healthcheck ["--interval=5s" "--timeout=3s" "--retries=3"] "CMD" "/app/check.sh --quiet")
6 6
 (healthcheck "CMD")
7 7
 (healthcheck "CMD" "a b")
8 8
 (healthcheck ["--timeout=3s"] "CMD" "foo")
... ...
@@ -28,6 +28,10 @@ const (
28 28
 	// than this, the check is considered to have failed.
29 29
 	defaultProbeTimeout = 30 * time.Second
30 30
 
31
+	// Default number of consecutive failures of the health check
32
+	// for the container to be considered unhealthy.
33
+	defaultProbeRetries = 3
34
+
31 35
 	// Shut down a container if it becomes Unhealthy.
32 36
 	defaultExitOnUnhealthy = true
33 37
 
... ...
@@ -111,7 +115,7 @@ func handleProbeResult(d *Daemon, c *container.Container, result *types.Healthch
111 111
 
112 112
 	retries := c.Config.Healthcheck.Retries
113 113
 	if retries <= 0 {
114
-		retries = 1 // Default if unset or set to an invalid value
114
+		retries = defaultProbeRetries
115 115
 	}
116 116
 
117 117
 	h := c.State.Health
... ...
@@ -1496,7 +1496,7 @@ The options that can appear before `CMD` are:
1496 1496
 
1497 1497
 * `--interval=DURATION` (default: `30s`)
1498 1498
 * `--timeout=DURATION` (default: `30s`)
1499
-* `--retries=N` (default: `1`)
1499
+* `--retries=N` (default: `3`)
1500 1500
 
1501 1501
 The health check will first run **interval** seconds after the container is
1502 1502
 started, and then again **interval** seconds after each previous check completes.