summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-07-16 16:38:09 +0200
committerGitHub <noreply@github.com>2019-07-16 16:38:09 +0200
commit386ffd28d64a19a9c244ab477a45c4d2fa239ff6 (patch)
tree3662570d38a80c95841b3bc57606702307234e42 /libpod
parent7e4db4452fdece411e0ee8c7c8805c0c636f49ea (diff)
parent5ed2de158ff8a234f0d5d8380bd44a41c616225c (diff)
downloadpodman-386ffd28d64a19a9c244ab477a45c4d2fa239ff6.tar.gz
podman-386ffd28d64a19a9c244ab477a45c4d2fa239ff6.tar.bz2
podman-386ffd28d64a19a9c244ab477a45c4d2fa239ff6.zip
Merge pull request #3539 from stefanb2/topic-pr-3507-3525
Fix handling of healthcheck from image
Diffstat (limited to 'libpod')
-rw-r--r--libpod/healthcheck.go23
1 files changed, 16 insertions, 7 deletions
diff --git a/libpod/healthcheck.go b/libpod/healthcheck.go
index f4ea6c694..8ed2b12e1 100644
--- a/libpod/healthcheck.go
+++ b/libpod/healthcheck.go
@@ -107,16 +107,25 @@ 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
}
+ if len(newCommand) < 1 || newCommand[0] == "" {
+ return HealthCheckNotDefined, errors.Errorf("container %s has no defined healthcheck", c.ID())
+ }
captureBuffer := bufio.NewWriter(&capture)
hcw := hcWriteCloser{
captureBuffer,