mirror of
https://github.com/containers/podman.git
synced 2025-06-26 12:56:45 +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,
|
VolumesFrom: cc.HostConfig.VolumesFrom,
|
||||||
Workdir: cc.Config.WorkingDir,
|
Workdir: cc.Config.WorkingDir,
|
||||||
Net: &netInfo,
|
Net: &netInfo,
|
||||||
|
HealthInterval: DefaultHealthCheckInterval,
|
||||||
|
HealthRetries: DefaultHealthCheckRetries,
|
||||||
|
HealthTimeout: DefaultHealthCheckTimeout,
|
||||||
|
HealthStartPeriod: DefaultHealthCheckStartPeriod,
|
||||||
}
|
}
|
||||||
if !rootless.IsRootless() {
|
if !rootless.IsRootless() {
|
||||||
var ulimits []string
|
var ulimits []string
|
||||||
@ -527,11 +531,19 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, rtc *c
|
|||||||
finCmd = finCmd[:len(finCmd)-1]
|
finCmd = finCmd[:len(finCmd)-1]
|
||||||
}
|
}
|
||||||
cliOpts.HealthCmd = finCmd
|
cliOpts.HealthCmd = finCmd
|
||||||
|
if cc.Config.Healthcheck.Interval > 0 {
|
||||||
cliOpts.HealthInterval = cc.Config.Healthcheck.Interval.String()
|
cliOpts.HealthInterval = cc.Config.Healthcheck.Interval.String()
|
||||||
|
}
|
||||||
|
if cc.Config.Healthcheck.Retries > 0 {
|
||||||
cliOpts.HealthRetries = uint(cc.Config.Healthcheck.Retries)
|
cliOpts.HealthRetries = uint(cc.Config.Healthcheck.Retries)
|
||||||
|
}
|
||||||
|
if cc.Config.Healthcheck.StartPeriod > 0 {
|
||||||
cliOpts.HealthStartPeriod = cc.Config.Healthcheck.StartPeriod.String()
|
cliOpts.HealthStartPeriod = cc.Config.Healthcheck.StartPeriod.String()
|
||||||
|
}
|
||||||
|
if cc.Config.Healthcheck.Timeout > 0 {
|
||||||
cliOpts.HealthTimeout = cc.Config.Healthcheck.Timeout.String()
|
cliOpts.HealthTimeout = cc.Config.Healthcheck.Timeout.String()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// specgen assumes the image name is arg[0]
|
// specgen assumes the image name is arg[0]
|
||||||
cmd := []string{cc.Config.Image}
|
cmd := []string{cc.Config.Image}
|
||||||
|
@ -356,3 +356,14 @@ t GET containers/$cid/json 200 \
|
|||||||
.HostConfig.NetworkMode="bridge"
|
.HostConfig.NetworkMode="bridge"
|
||||||
|
|
||||||
t DELETE containers/$cid?v=true 204
|
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