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 --- cmd/podman/common/create.go | 8 ++++---- cmd/podman/common/create_opts.go | 9 +++++---- cmd/podman/common/default.go | 9 +-------- 3 files changed, 10 insertions(+), 16 deletions(-) (limited to 'cmd/podman/common') diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go index 32d227e65..b60169990 100644 --- a/cmd/podman/common/create.go +++ b/cmd/podman/common/create.go @@ -257,7 +257,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions, healthIntervalFlagName := "health-interval" createFlags.StringVar( &cf.HealthInterval, - healthIntervalFlagName, DefaultHealthCheckInterval, + healthIntervalFlagName, define.DefaultHealthCheckInterval, "set an interval for the healthchecks (a value of disable results in no automatic timer setup)", ) _ = cmd.RegisterFlagCompletionFunc(healthIntervalFlagName, completion.AutocompleteNone) @@ -265,7 +265,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions, healthRetriesFlagName := "health-retries" createFlags.UintVar( &cf.HealthRetries, - healthRetriesFlagName, DefaultHealthCheckRetries, + healthRetriesFlagName, define.DefaultHealthCheckRetries, "the number of retries allowed before a healthcheck is considered to be unhealthy", ) _ = cmd.RegisterFlagCompletionFunc(healthRetriesFlagName, completion.AutocompleteNone) @@ -273,7 +273,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions, healthStartPeriodFlagName := "health-start-period" createFlags.StringVar( &cf.HealthStartPeriod, - healthStartPeriodFlagName, DefaultHealthCheckStartPeriod, + healthStartPeriodFlagName, define.DefaultHealthCheckStartPeriod, "the initialization time needed for a container to bootstrap", ) _ = cmd.RegisterFlagCompletionFunc(healthStartPeriodFlagName, completion.AutocompleteNone) @@ -281,7 +281,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions, healthTimeoutFlagName := "health-timeout" createFlags.StringVar( &cf.HealthTimeout, - healthTimeoutFlagName, DefaultHealthCheckTimeout, + healthTimeoutFlagName, define.DefaultHealthCheckTimeout, "the maximum time allowed to complete the healthcheck before an interval is considered failed", ) _ = cmd.RegisterFlagCompletionFunc(healthTimeoutFlagName, completion.AutocompleteNone) diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go index f2335a2be..297188a45 100644 --- a/cmd/podman/common/create_opts.go +++ b/cmd/podman/common/create_opts.go @@ -11,6 +11,7 @@ import ( "github.com/containers/common/pkg/cgroups" "github.com/containers/common/pkg/config" "github.com/containers/podman/v3/cmd/podman/registry" + "github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/libpod/network/types" "github.com/containers/podman/v3/pkg/api/handlers" "github.com/containers/podman/v3/pkg/domain/entities" @@ -304,10 +305,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, + HealthInterval: define.DefaultHealthCheckInterval, + HealthRetries: define.DefaultHealthCheckRetries, + HealthTimeout: define.DefaultHealthCheckTimeout, + HealthStartPeriod: define.DefaultHealthCheckStartPeriod, } if !rootless.IsRootless() { var ulimits []string diff --git a/cmd/podman/common/default.go b/cmd/podman/common/default.go index 7e025c449..7997e761c 100644 --- a/cmd/podman/common/default.go +++ b/cmd/podman/common/default.go @@ -5,14 +5,7 @@ import ( ) var ( - // DefaultHealthCheckInterval default value - DefaultHealthCheckInterval = "30s" - // DefaultHealthCheckRetries default value - DefaultHealthCheckRetries uint = 3 - // DefaultHealthCheckStartPeriod default value - DefaultHealthCheckStartPeriod = "0s" - // DefaultHealthCheckTimeout default value - DefaultHealthCheckTimeout = "30s" + // DefaultImageVolume default value DefaultImageVolume = "bind" // Pull in configured json library -- cgit v1.2.3-54-g00ecf