mirror of
https://github.com/containers/podman.git
synced 2025-06-24 19:42:56 +08:00
Fixed healthcheck default values when container created via compat API
Fixes #11225 Signed-off-by: Milivoje Legenovic <m.legenovic@gmail.com>
This commit is contained in:
@ -401,6 +401,10 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, rtc *c
|
||||
VolumesFrom: cc.HostConfig.VolumesFrom,
|
||||
Workdir: cc.Config.WorkingDir,
|
||||
Net: &netInfo,
|
||||
HealthInterval: DefaultHealthCheckInterval,
|
||||
HealthRetries: DefaultHealthCheckRetries,
|
||||
HealthTimeout: DefaultHealthCheckTimeout,
|
||||
HealthStartPeriod: DefaultHealthCheckStartPeriod,
|
||||
}
|
||||
if !rootless.IsRootless() {
|
||||
var ulimits []string
|
||||
@ -527,11 +531,19 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, rtc *c
|
||||
finCmd = finCmd[:len(finCmd)-1]
|
||||
}
|
||||
cliOpts.HealthCmd = finCmd
|
||||
if cc.Config.Healthcheck.Interval > 0 {
|
||||
cliOpts.HealthInterval = cc.Config.Healthcheck.Interval.String()
|
||||
}
|
||||
if cc.Config.Healthcheck.Retries > 0 {
|
||||
cliOpts.HealthRetries = uint(cc.Config.Healthcheck.Retries)
|
||||
}
|
||||
if cc.Config.Healthcheck.StartPeriod > 0 {
|
||||
cliOpts.HealthStartPeriod = cc.Config.Healthcheck.StartPeriod.String()
|
||||
}
|
||||
if cc.Config.Healthcheck.Timeout > 0 {
|
||||
cliOpts.HealthTimeout = cc.Config.Healthcheck.Timeout.String()
|
||||
}
|
||||
}
|
||||
|
||||
// specgen assumes the image name is arg[0]
|
||||
cmd := []string{cc.Config.Image}
|
||||
|
@ -356,3 +356,14 @@ t GET containers/$cid/json 200 \
|
||||
.HostConfig.NetworkMode="bridge"
|
||||
|
||||
t DELETE containers/$cid?v=true 204
|
||||
|
||||
# Test Compat Create with healthcheck, check default values
|
||||
t POST containers/create Image=$IMAGE Cmd='["top"]' Healthcheck='{"Test":["true"]}' 201 \
|
||||
.Id~[0-9a-f]\\{64\\}
|
||||
cid=$(jq -r '.Id' <<<"$output")
|
||||
t GET containers/$cid/json 200 \
|
||||
.Config.Healthcheck.Interval=30000000000 \
|
||||
.Config.Healthcheck.Timeout=30000000000 \
|
||||
.Config.Healthcheck.Retries=3
|
||||
|
||||
t DELETE containers/$cid?v=true 204
|
||||
|
Reference in New Issue
Block a user