From 350727570b6f033c5c509a62ec8bfc4827e1c2fc Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 27 Apr 2020 11:21:53 +0200 Subject: podman: special case health-cmd none now we have to pass down this information to libpod Signed-off-by: Giuseppe Scrivano --- cmd/podman/common/specgen.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go index 488843f41..ead67ee92 100644 --- a/cmd/podman/common/specgen.go +++ b/cmd/podman/common/specgen.go @@ -623,10 +623,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, -- cgit v1.2.3-54-g00ecf From 1cd484e13ff4c4b137e1f63c3b9aec0f5e4ef504 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 27 Apr 2020 11:22:27 +0200 Subject: specgen: read healthchecks from the image if there is no healthcheck configuration specified, read it from the image. Signed-off-by: Giuseppe Scrivano --- pkg/specgen/generate/container.go | 7 +++++++ 1 file changed, 7 insertions(+) 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) -- cgit v1.2.3-54-g00ecf From eab41cac6f77e32552838b16253ff23aad13c5a5 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 27 Apr 2020 11:31:35 +0200 Subject: podman: handle --no-healthcheck Signed-off-by: Giuseppe Scrivano --- cmd/podman/common/specgen.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go index ead67ee92..850fb11ec 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) -- cgit v1.2.3-54-g00ecf From 00233e0311810df32bebd06398ce93e92779e1d5 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 27 Apr 2020 11:24:09 +0200 Subject: test: enable healthcheck tests Signed-off-by: Giuseppe Scrivano --- test/e2e/healthcheck_run_test.go | 1 - 1 file changed, 1 deletion(-) 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) -- cgit v1.2.3-54-g00ecf