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 /cmd/podman/common/specgen.go | |
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
Diffstat (limited to 'cmd/podman/common/specgen.go')
-rw-r--r-- | cmd/podman/common/specgen.go | 20 |
1 files changed, 16 insertions, 4 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, |