summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-04-20 08:35:57 -0400
committerGitHub <noreply@github.com>2022-04-20 08:35:57 -0400
commit51237bba2c126f1ca72b460452633fd8210dd56b (patch)
treec838b334351b64d6802acba09173f1339d4bd207
parent9c36d8458c1b4d4ab504a7ff54db87489cbb0254 (diff)
parent519535daa0e5c4ce27a77cea0fb24d87f6ee8c54 (diff)
downloadpodman-51237bba2c126f1ca72b460452633fd8210dd56b.tar.gz
podman-51237bba2c126f1ca72b460452633fd8210dd56b.tar.bz2
podman-51237bba2c126f1ca72b460452633fd8210dd56b.zip
Merge pull request #13928 from flouthoc/healthcheck-defaults
healthcheck: set default healthcheck `Interval` if not specified in image
-rw-r--r--pkg/specgen/generate/container.go19
-rw-r--r--test/e2e/healthcheck_run_test.go2
2 files changed, 16 insertions, 5 deletions
diff --git a/pkg/specgen/generate/container.go b/pkg/specgen/generate/container.go
index f7ea2edfa..5f4218899 100644
--- a/pkg/specgen/generate/container.go
+++ b/pkg/specgen/generate/container.go
@@ -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
// but inspect will take care of it.
s.HealthConfig = inspectData.HealthCheck
- if s.HealthConfig != nil && s.HealthConfig.Timeout == 0 {
- hct, err := time.ParseDuration(define.DefaultHealthCheckTimeout)
- if err != nil {
- return nil, err
+ if s.HealthConfig != nil {
+ if s.HealthConfig.Timeout == 0 {
+ hct, err := time.ParseDuration(define.DefaultHealthCheckTimeout)
+ 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
}
}
diff --git a/test/e2e/healthcheck_run_test.go b/test/e2e/healthcheck_run_test.go
index 757eaed20..23f1a1dbf 100644
--- a/test/e2e/healthcheck_run_test.go
+++ b/test/e2e/healthcheck_run_test.go
@@ -325,6 +325,8 @@ HEALTHCHECK CMD ls -l / 2>&1`, ALPINE)
inspect := podmanTest.InspectContainer("hctest")
// Check to make sure a default time value was added
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
Expect(inspect[0].Config.Healthcheck.Test).To(Equal([]string{"CMD-SHELL", "ls -l / 2>&1"}))
})