Add comment for jsonMarshal command

* also, change makeHealthCheck to the standard test command structure

Signed-off-by: Liang Chu-Xuan <karta0807913@gmail.com>
This commit is contained in:
Liang Chu-Xuan
2022-12-17 02:44:45 +00:00
parent 7bd1dbb756
commit 070b69205c
2 changed files with 4 additions and 1 deletions

View File

@ -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{

View File

@ -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() {