From 070b69205c1b891c813318ca462b052345dd1822 Mon Sep 17 00:00:00 2001 From: Liang Chu-Xuan Date: Sat, 17 Dec 2022 02:44:45 +0000 Subject: [PATCH] Add comment for jsonMarshal command * also, change makeHealthCheck to the standard test command structure Signed-off-by: Liang Chu-Xuan --- pkg/specgen/generate/kube/kube.go | 3 +++ test/e2e/play_kube_test.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/specgen/generate/kube/kube.go b/pkg/specgen/generate/kube/kube.go index 2451f676bf..c806760a80 100644 --- a/pkg/specgen/generate/kube/kube.go +++ b/pkg/specgen/generate/kube/kube.go @@ -523,6 +523,7 @@ func probeToHealthConfig(probe *v1.Probe) (*manifest.Schema2HealthConfig, error) // configure healthcheck on the basis of Handler Actions. switch { case probeHandler.Exec != nil: + // `makeHealthCheck` function can accept a json array as the command. cmd, err := json.Marshal(probeHandler.Exec.Command) if err != nil { return nil, err @@ -618,6 +619,8 @@ func makeHealthCheck(inCmd string, interval int32, retries int32, timeout int32, // ...otherwise pass it to "/bin/sh -c" inside the container cmd = []string{define.HealthConfigTestCmdShell} cmd = append(cmd, strings.Split(inCmd, " ")...) + } else { + cmd = append([]string{define.HealthConfigTestCmd}, cmd...) } } hc := manifest.Schema2HealthConfig{ diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index b10f9333cb..13dedb9a5e 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -1754,7 +1754,7 @@ var _ = Describe("Podman play kube", func() { inspect.WaitWithDefaultTimeout() healthcheckcmd := inspect.OutputToString() // check if CMD-SHELL based equivalent health check is added to container - Expect(healthcheckcmd).To(ContainSubstring("[echo hello]")) + Expect(healthcheckcmd).To(ContainSubstring("[CMD echo hello]")) }) It("podman play kube liveness probe should fail", func() {