summaryrefslogtreecommitdiff
path: root/libpod/healthcheck.go
diff options
context:
space:
mode:
authorStefan Becker <chemobejk@gmail.com>2019-07-09 20:19:20 +0300
committerStefan Becker <chemobejk@gmail.com>2019-07-16 07:01:43 +0300
commitdd0ea08cefce43b4ca5e468a4bafb909f877cd58 (patch)
tree9ccc7b47c2efd9a1a60032f1e7673fcc0275d4db /libpod/healthcheck.go
parentd2291ecdd514befd18a8b57ff2c7a8ef0cf04ba8 (diff)
downloadpodman-dd0ea08cefce43b4ca5e468a4bafb909f877cd58.tar.gz
podman-dd0ea08cefce43b4ca5e468a4bafb909f877cd58.tar.bz2
podman-dd0ea08cefce43b4ca5e468a4bafb909f877cd58.zip
healthcheck: improve command list parser
- remove duplicate check, already called in HealthCheck() - reject zero-length command list and empty command string as errorneous - support all Docker command list keywords: NONE, CMD or CMD-SHELL - use Docker default "/bin/sh -c" for CMD-SHELL Fixes #3507 Signed-off-by: Stefan Becker <chemobejk@gmail.com>
Diffstat (limited to 'libpod/healthcheck.go')
-rw-r--r--libpod/healthcheck.go20
1 files changed, 13 insertions, 7 deletions
diff --git a/libpod/healthcheck.go b/libpod/healthcheck.go
index f4ea6c694..e9bf984e2 100644
--- a/libpod/healthcheck.go
+++ b/libpod/healthcheck.go
@@ -107,14 +107,20 @@ func (c *Container) runHealthCheck() (HealthCheckStatus, error) {
capture bytes.Buffer
inStartPeriod bool
)
- hcStatus, err := checkHealthCheckCanBeRun(c)
- if err != nil {
- return hcStatus, err
- }
hcCommand := c.HealthCheckConfig().Test
- if len(hcCommand) > 0 && hcCommand[0] == "CMD-SHELL" {
- newCommand = []string{"sh", "-c", strings.Join(hcCommand[1:], " ")}
- } else {
+ if len(hcCommand) < 1 {
+ return HealthCheckNotDefined, errors.Errorf("container %s has no defined healthcheck", c.ID())
+ }
+ switch hcCommand[0] {
+ case "", "NONE":
+ return HealthCheckNotDefined, errors.Errorf("container %s has no defined healthcheck", c.ID())
+ case "CMD":
+ newCommand = hcCommand[1:]
+ case "CMD-SHELL":
+ // TODO: SHELL command from image not available in Container - use Docker default
+ newCommand = []string{"/bin/sh", "-c", strings.Join(hcCommand[1:], " ")}
+ default:
+ // command supplied on command line - pass as-is
newCommand = hcCommand
}
captureBuffer := bufio.NewWriter(&capture)