Skip to content

Commit

Permalink
create: apply defaults on image healthcheck options
Browse files Browse the repository at this point in the history
If the image doesn't provide any options, e.g. interval, timeout, etc.,
then apply the Docker defaults when creating the container. Otherwise
the defaults will be left 0 and podman doesn't schedule the healtcheck
service & timer for the container or incorrectly reports unhealthy state
when the check is executed.

Fixes containers#3525

Signed-off-by: Stefan Becker <[email protected]>
  • Loading branch information
stefanb2 committed Jul 16, 2019
1 parent dd0ea08 commit 33001a9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cmd/podman/shared/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,24 @@ func CreateContainer(ctx context.Context, c *GenericCLIResults, runtime *libpod.
if err != nil {
return nil, nil, errors.Wrapf(err, "unable to get healthcheck for %s", c.InputArgs[0])
}

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
}
}
}
}
}
Expand Down

0 comments on commit 33001a9

Please sign in to comment.