From afedb839173cfb5bbc0e069d40d6a6bf5ab60a29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Rod=C3=A1k?= Date: Thu, 24 Oct 2024 13:23:44 +0200 Subject: [PATCH] Add Startup HealthCheck configuration to the podman inspect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Rodák --- libpod/container_inspect.go | 2 ++ libpod/define/container_inspect.go | 2 ++ test/system/220-healthcheck.bats | 3 +++ 3 files changed, 7 insertions(+) diff --git a/libpod/container_inspect.go b/libpod/container_inspect.go index 55055b43ee..b3d680bcb5 100644 --- a/libpod/container_inspect.go +++ b/libpod/container_inspect.go @@ -427,6 +427,8 @@ func (c *Container) generateInspectContainerConfig(spec *spec.Spec) *define.Insp ctrConfig.StopSignal = signal.ToDockerFormat(c.config.StopSignal) // TODO: should JSON deep copy this to ensure internal pointers don't // leak. + ctrConfig.StartupHealthCheck = c.config.StartupHealthCheckConfig + ctrConfig.Healthcheck = c.config.HealthCheckConfig ctrConfig.HealthcheckOnFailureAction = c.config.HealthCheckOnFailureAction.String() diff --git a/libpod/define/container_inspect.go b/libpod/define/container_inspect.go index 4062e7bc9d..1f5b225c3f 100644 --- a/libpod/define/container_inspect.go +++ b/libpod/define/container_inspect.go @@ -57,6 +57,8 @@ type InspectContainerConfig struct { Annotations map[string]string `json:"Annotations"` // Container stop signal StopSignal string `json:"StopSignal"` + // Configured startup healthcheck for the container + StartupHealthCheck *StartupHealthCheck `json:"StartupHealthCheck,omitempty"` // Configured healthcheck for the container Healthcheck *manifest.Schema2HealthConfig `json:"Healthcheck,omitempty"` // HealthcheckOnFailureAction defines an action to take once the container turns unhealthy. diff --git a/test/system/220-healthcheck.bats b/test/system/220-healthcheck.bats index 43c8e1d012..662ecf8ff6 100644 --- a/test/system/220-healthcheck.bats +++ b/test/system/220-healthcheck.bats @@ -67,6 +67,9 @@ function _check_health { run_podman inspect $ctrname --format "{{.Config.HealthcheckOnFailureAction}}" is "$output" "kill" "on-failure action is set to kill" + run_podman inspect $ctrname --format "{{.Config.StartupHealthCheck.Test}}" + is "$output" "[CMD-SHELL /home/podman/healthcheck]" ".Config.StartupHealthCheck.Test" + current_time=$(date --iso-8601=ns) # We can't check for 'starting' because a 1-second interval is too # short; it could run healthcheck before we get to our first check.