Skip to content

Commit

Permalink
create: ignore check if image has HEALTHCHECK NONE
Browse files Browse the repository at this point in the history
If the image was built with "HEALTHCHECK NONE" then we should create a
container without healthcheck configuration. Otherwise executing the
healthcheck on the container will return "unhealthy" instead of the
correct error message that the container doesn't have a healthcheck.

We also ignore the healthcheck configuration if the command list is
empty or the command string is empty.

Fixes containers#3525

Signed-off-by: Stefan Becker <[email protected]>
  • Loading branch information
stefanb2 committed Jul 16, 2019
1 parent 33001a9 commit 5caf218
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions cmd/podman/shared/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,26 @@ func CreateContainer(ctx context.Context, c *GenericCLIResults, runtime *libpod.
}

if healthCheck != nil {
// apply defaults if image doesn't override them
if healthCheck.Interval == 0 {
healthCheck.Interval = 30 * time.Second
}
if healthCheck.Timeout == 0 {
healthCheck.Timeout = 30 * time.Second
}
/* Docker default is 0s, so the following would be a no-op
if healthCheck.StartPeriod == 0 {
healthCheck.StartPeriod = 0 * time.Second
}
*/
if healthCheck.Retries == 0 {
healthCheck.Retries = 3
hcCommand := healthCheck.Test
if len(hcCommand) < 1 || hcCommand[0] == "" || hcCommand[0] == "NONE" {
// disable health check
healthCheck = nil
} else {
// apply defaults if image doesn't override them
if healthCheck.Interval == 0 {
healthCheck.Interval = 30 * time.Second
}
if healthCheck.Timeout == 0 {
healthCheck.Timeout = 30 * time.Second
}
/* Docker default is 0s, so the following would be a no-op
if healthCheck.StartPeriod == 0 {
healthCheck.StartPeriod = 0 * time.Second
}
*/
if healthCheck.Retries == 0 {
healthCheck.Retries = 3
}
}
}
}
Expand Down

0 comments on commit 5caf218

Please sign in to comment.