From 2a524fcaec4e6f66461d7cdda1bb73ed7c50f026 Mon Sep 17 00:00:00 2001 From: Brent Baude Date: Wed, 15 Dec 2021 13:32:57 -0600 Subject: fix healthcheck timeouts and ut8 coercion this commit fixes two bugs and adds regression tests. when getting healthcheck values from an image, if the image does not have a timeout defined, this resulted in a 0 value for timeout. The default as described in the man pages is 30s. when inspecting a container with a healthcheck command, a customer observed that the &, <, and > characters were being converted into a unicode escape value. It turns out json marshalling will by default coerce string values to ut8. Fixes: bz2028408 Signed-off-by: Brent Baude --- pkg/specgen/generate/container.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'pkg') diff --git a/pkg/specgen/generate/container.go b/pkg/specgen/generate/container.go index 57676db10..5ec7c7b03 100644 --- a/pkg/specgen/generate/container.go +++ b/pkg/specgen/generate/container.go @@ -4,6 +4,7 @@ import ( "context" "os" "strings" + "time" "github.com/containers/common/libimage" "github.com/containers/podman/v3/libpod" @@ -64,6 +65,13 @@ 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 + } + s.HealthConfig.Timeout = hct + } } // Image stop signal -- cgit v1.2.3-54-g00ecf