Skip to content

Commit

Permalink
Merge pull request moby#23232 from thaJeztah/update-default-retries
Browse files Browse the repository at this point in the history
Healthcheck: set default retries to 3
  • Loading branch information
vdemeester committed Jun 4, 2016
2 parents 521f79b + 50e470f commit 3db23a4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion builder/dockerfile/parser/testfiles/health/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM debian
ADD check.sh main.sh /app/
CMD /app/main.sh
HEALTHCHECK
HEALTHCHECK --interval=5s --timeout=3s --retries=1 \
HEALTHCHECK --interval=5s --timeout=3s --retries=3 \
CMD /app/check.sh --quiet
HEALTHCHECK CMD
HEALTHCHECK CMD a b
Expand Down
2 changes: 1 addition & 1 deletion builder/dockerfile/parser/testfiles/health/result
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(add "check.sh" "main.sh" "/app/")
(cmd "/app/main.sh")
(healthcheck)
(healthcheck ["--interval=5s" "--timeout=3s" "--retries=1"] "CMD" "/app/check.sh --quiet")
(healthcheck ["--interval=5s" "--timeout=3s" "--retries=3"] "CMD" "/app/check.sh --quiet")
(healthcheck "CMD")
(healthcheck "CMD" "a b")
(healthcheck ["--timeout=3s"] "CMD" "foo")
Expand Down
6 changes: 5 additions & 1 deletion daemon/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ const (
// than this, the check is considered to have failed.
defaultProbeTimeout = 30 * time.Second

// Default number of consecutive failures of the health check
// for the container to be considered unhealthy.
defaultProbeRetries = 3

// Shut down a container if it becomes Unhealthy.
defaultExitOnUnhealthy = true

Expand Down Expand Up @@ -111,7 +115,7 @@ func handleProbeResult(d *Daemon, c *container.Container, result *types.Healthch

retries := c.Config.Healthcheck.Retries
if retries <= 0 {
retries = 1 // Default if unset or set to an invalid value
retries = defaultProbeRetries
}

h := c.State.Health
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ The options that can appear before `CMD` are:

* `--interval=DURATION` (default: `30s`)
* `--timeout=DURATION` (default: `30s`)
* `--retries=N` (default: `1`)
* `--retries=N` (default: `3`)

The health check will first run **interval** seconds after the container is
started, and then again **interval** seconds after each previous check completes.
Expand Down

0 comments on commit 3db23a4

Please sign in to comment.