mirror of
https://github.com/containers/podman.git
synced 2025-06-21 17:38:12 +08:00
Merge pull request #13928 from flouthoc/healthcheck-defaults
healthcheck: set default healthcheck `Interval` if not specified in image
This commit is contained in:
@ -67,12 +67,21 @@ func CompleteSpec(ctx context.Context, r *libpod.Runtime, s *specgen.SpecGenerat
|
|||||||
// NOTE: the health check is only set for Docker images
|
// NOTE: the health check is only set for Docker images
|
||||||
// but inspect will take care of it.
|
// but inspect will take care of it.
|
||||||
s.HealthConfig = inspectData.HealthCheck
|
s.HealthConfig = inspectData.HealthCheck
|
||||||
if s.HealthConfig != nil && s.HealthConfig.Timeout == 0 {
|
if s.HealthConfig != nil {
|
||||||
hct, err := time.ParseDuration(define.DefaultHealthCheckTimeout)
|
if s.HealthConfig.Timeout == 0 {
|
||||||
if err != nil {
|
hct, err := time.ParseDuration(define.DefaultHealthCheckTimeout)
|
||||||
return nil, err
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
s.HealthConfig.Timeout = hct
|
||||||
|
}
|
||||||
|
if s.HealthConfig.Interval == 0 {
|
||||||
|
hct, err := time.ParseDuration(define.DefaultHealthCheckInterval)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
s.HealthConfig.Interval = hct
|
||||||
}
|
}
|
||||||
s.HealthConfig.Timeout = hct
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,6 +325,8 @@ HEALTHCHECK CMD ls -l / 2>&1`, ALPINE)
|
|||||||
inspect := podmanTest.InspectContainer("hctest")
|
inspect := podmanTest.InspectContainer("hctest")
|
||||||
// Check to make sure a default time value was added
|
// Check to make sure a default time value was added
|
||||||
Expect(inspect[0].Config.Healthcheck.Timeout).To(BeNumerically("==", 30000000000))
|
Expect(inspect[0].Config.Healthcheck.Timeout).To(BeNumerically("==", 30000000000))
|
||||||
|
// Check to make sure a default time interval value was added
|
||||||
|
Expect(inspect[0].Config.Healthcheck.Interval).To(BeNumerically("==", 30000000000))
|
||||||
// Check to make sure characters were not coerced to utf8
|
// Check to make sure characters were not coerced to utf8
|
||||||
Expect(inspect[0].Config.Healthcheck.Test).To(Equal([]string{"CMD-SHELL", "ls -l / 2>&1"}))
|
Expect(inspect[0].Config.Healthcheck.Test).To(Equal([]string{"CMD-SHELL", "ls -l / 2>&1"}))
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user