summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Becker <chemobejk@gmail.com>2019-07-09 21:14:36 +0300
committerStefan Becker <chemobejk@gmail.com>2019-07-16 07:01:43 +0300
commit33001a9028d0ad12d2992dda295fd570714ca237 (patch)
tree3d488bd3eecc3b0905fa4bb8c60c9a1df55505b8
parentdd0ea08cefce43b4ca5e468a4bafb909f877cd58 (diff)
downloadpodman-33001a9028d0ad12d2992dda295fd570714ca237.tar.gz
podman-33001a9028d0ad12d2992dda295fd570714ca237.tar.bz2
podman-33001a9028d0ad12d2992dda295fd570714ca237.zip
create: apply defaults on image healthcheck options
If the image doesn't provide any options, e.g. interval, timeout, etc., then apply the Docker defaults when creating the container. Otherwise the defaults will be left 0 and podman doesn't schedule the healtcheck service & timer for the container or incorrectly reports unhealthy state when the check is executed. Fixes #3525 Signed-off-by: Stefan Becker <chemobejk@gmail.com>
-rw-r--r--cmd/podman/shared/create.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/cmd/podman/shared/create.go b/cmd/podman/shared/create.go
index 17455c4c9..9ce20047b 100644
--- a/cmd/podman/shared/create.go
+++ b/cmd/podman/shared/create.go
@@ -115,6 +115,24 @@ func CreateContainer(ctx context.Context, c *GenericCLIResults, runtime *libpod.
if err != nil {
return nil, nil, errors.Wrapf(err, "unable to get healthcheck for %s", c.InputArgs[0])
}
+
+ if healthCheck != nil {
+ // apply defaults if image doesn't override them
+ if healthCheck.Interval == 0 {
+ healthCheck.Interval = 30 * time.Second
+ }
+ if healthCheck.Timeout == 0 {
+ healthCheck.Timeout = 30 * time.Second
+ }
+ /* Docker default is 0s, so the following would be a no-op
+ if healthCheck.StartPeriod == 0 {
+ healthCheck.StartPeriod = 0 * time.Second
+ }
+ */
+ if healthCheck.Retries == 0 {
+ healthCheck.Retries = 3
+ }
+ }
}
}
}