diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-04-27 15:40:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-27 15:40:24 +0200 |
commit | fdf64f0c66be4569732b830ce60c98f98a7efe64 (patch) | |
tree | 6cda34f02000425c44a944855b7f193ebb7c556a | |
parent | 529824ec1e02e9b7ea893bbab35179ef16d4661d (diff) | |
parent | 00233e0311810df32bebd06398ce93e92779e1d5 (diff) | |
download | podman-fdf64f0c66be4569732b830ce60c98f98a7efe64.tar.gz podman-fdf64f0c66be4569732b830ce60c98f98a7efe64.tar.bz2 podman-fdf64f0c66be4569732b830ce60c98f98a7efe64.zip |
Merge pull request #5994 from giuseppe/fix-healthchecks
v2, podman: fix healthchecks
-rw-r--r-- | cmd/podman/common/specgen.go | 20 | ||||
-rw-r--r-- | pkg/specgen/generate/container.go | 7 | ||||
-rw-r--r-- | test/e2e/healthcheck_run_test.go | 1 |
3 files changed, 23 insertions, 5 deletions
diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go index ab87a2fc7..ba9022aff 100644 --- a/cmd/podman/common/specgen.go +++ b/cmd/podman/common/specgen.go @@ -203,10 +203,17 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string s.User = c.User inputCommand := args[1:] if len(c.HealthCmd) > 0 { + if c.NoHealthCheck { + return errors.New("Cannot specify both --no-healthcheck and --health-cmd") + } s.HealthConfig, err = makeHealthCheckFromCli(c.HealthCmd, c.HealthInterval, c.HealthRetries, c.HealthTimeout, c.HealthStartPeriod) if err != nil { return err } + } else if c.NoHealthCheck { + s.HealthConfig = &manifest.Schema2HealthConfig{ + Test: []string{"NONE"}, + } } userNS := ns.UsernsMode(c.UserNS) @@ -624,10 +631,15 @@ func makeHealthCheckFromCli(inCmd, interval string, retries uint, timeout, start // first try to parse option value as JSON array of strings... cmd := []string{} - err := json.Unmarshal([]byte(inCmd), &cmd) - if err != nil { - // ...otherwise pass it to "/bin/sh -c" inside the container - cmd = []string{"CMD-SHELL", inCmd} + + if inCmd == "none" { + cmd = []string{"NONE"} + } else { + err := json.Unmarshal([]byte(inCmd), &cmd) + if err != nil { + // ...otherwise pass it to "/bin/sh -c" inside the container + cmd = []string{"CMD-SHELL", inCmd} + } } hc := manifest.Schema2HealthConfig{ Test: cmd, diff --git a/pkg/specgen/generate/container.go b/pkg/specgen/generate/container.go index 9797ad572..669b1f05f 100644 --- a/pkg/specgen/generate/container.go +++ b/pkg/specgen/generate/container.go @@ -25,6 +25,13 @@ func CompleteSpec(ctx context.Context, r *libpod.Runtime, s *specgen.SpecGenerat return err } + if s.HealthConfig == nil { + s.HealthConfig, err = newImage.GetHealthCheck(ctx) + if err != nil { + return err + } + } + // Image stop signal if s.StopSignal == nil { stopSignal, err := newImage.StopSignal(ctx) diff --git a/test/e2e/healthcheck_run_test.go b/test/e2e/healthcheck_run_test.go index 58d473ca8..19a8658ac 100644 --- a/test/e2e/healthcheck_run_test.go +++ b/test/e2e/healthcheck_run_test.go @@ -18,7 +18,6 @@ var _ = Describe("Podman healthcheck run", func() { ) BeforeEach(func() { - Skip(v2fail) tempdir, err = CreateTempDirInTempDir() if err != nil { os.Exit(1) |