Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --no-healthcheck command to create/run #5300

Merged
merged 1 commit into from
Feb 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/podman/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,10 @@ func getCreateFlags(c *cliconfig.PodmanCommand) {
"name", "",
"Assign a name to the container",
)
createFlags.Bool(
"no-healthcheck", false,
"Disable healthchecks on container",
)
createFlags.Bool(
"oom-kill-disable", false,
"Disable OOM Killer",
Expand Down
5 changes: 3 additions & 2 deletions cmd/podman/shared/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,13 @@ func CreateContainer(ctx context.Context, c *GenericCLIResults, runtime *libpod.
imageName = newImage.ID()
}

// if the user disabled the healthcheck with "none", we skip adding it
// if the user disabled the healthcheck with "none" or the no-healthcheck
// options is provided, we skip adding it
healthCheckCommandInput := c.String("healthcheck-command")

// the user didn't disable the healthcheck but did pass in a healthcheck command
// now we need to make a healthcheck from the commandline input
if healthCheckCommandInput != "none" {
if healthCheckCommandInput != "none" && !c.Bool("no-healthcheck") {
if len(healthCheckCommandInput) > 0 {
healthCheck, err = makeHealthCheckFromCli(c)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions cmd/podman/shared/intermediate.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ func NewIntermediateLayer(c *cliconfig.PodmanCommand, remote bool) GenericCLIRes
m["memory-swappiness"] = newCRInt64(c, "memory-swappiness")
m["name"] = newCRString(c, "name")
m["network"] = newCRString(c, "network")
m["no-healthcheck"] = newCRBool(c, "no-healthcheck")
m["no-hosts"] = newCRBool(c, "no-hosts")
m["oom-kill-disable"] = newCRBool(c, "oom-kill-disable")
m["oom-score-adj"] = newCRInt(c, "oom-score-adj")
Expand Down
6 changes: 6 additions & 0 deletions completions/bash/podman
Original file line number Diff line number Diff line change
Expand Up @@ -1888,6 +1888,11 @@ _podman_container_run() {
--expose
--gidmap
--group-add
--health-cmd
--health-interval
--health-retries
--health-start-period
--health-timeout
--hostname -h
--http-proxy
--image-volume
Expand All @@ -1906,6 +1911,7 @@ _podman_container_run() {
--memory-reservation
--name
--network
--no-healthcheck
--no-hosts
--oom-score-adj
--pid
Expand Down
4 changes: 4 additions & 0 deletions docs/source/markdown/podman-create.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,10 @@ Valid values are:

Not implemented

**--no-healthcheck**=*true|false*

Disable any defined healthchecks for container.

**--no-hosts**=*true|false*

Do not create /etc/hosts for the container.
Expand Down
4 changes: 4 additions & 0 deletions docs/source/markdown/podman-run.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,10 @@ Valid _mode_ values are:

Not implemented.

**--no-healthcheck**=*true|false*

Disable any defined healthchecks for container.

**--no-hosts**=**true**|**false**

Do not create _/etc/hosts_ for the container.
Expand Down
20 changes: 20 additions & 0 deletions test/e2e/healthcheck_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,26 @@ var _ = Describe("Podman healthcheck run", func() {
Expect(session).To(ExitWithError())
})

It("podman disable healthcheck with --no-healthcheck on valid container", func() {
SkipIfRemote()
session := podmanTest.Podman([]string{"run", "-dt", "--no-healthcheck", "--name", "hc", healthcheck})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
hc := podmanTest.Podman([]string{"healthcheck", "run", "hc"})
hc.WaitWithDefaultTimeout()
Expect(hc.ExitCode()).To(Equal(125))
})

It("podman disable healthcheck with --health-cmd=none on valid container", func() {
SkipIfRemote()
session := podmanTest.Podman([]string{"run", "-dt", "--health-cmd", "none", "--name", "hc", healthcheck})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
hc := podmanTest.Podman([]string{"healthcheck", "run", "hc"})
hc.WaitWithDefaultTimeout()
Expect(hc.ExitCode()).To(Equal(125))
})

It("podman healthcheck on valid container", func() {
Skip("Extremely consistent flake - re-enable on debugging")
session := podmanTest.Podman([]string{"run", "-dt", "--name", "hc", healthcheck})
Expand Down