From 92a15085cb5ef8001694fa6119baf03d3ec7cefe Mon Sep 17 00:00:00 2001 From: Patrick Barrett Date: Fri, 16 May 2025 11:43:32 -0500 Subject: [PATCH 1/2] compat: fix Container State.Status JSON values This mirrors the conversion currently being done in `LibpodToContainer` into `LibpodToContainerJSON`, converting podman style statuses to docker style statuses as defined in their OpenAPI definition: https://docs.docker.com/reference/api/engine/version/v1.49/#tag/Container/operation/ContainerInspect Fixes: #17728 Signed-off-by: Patrick Barrett --- pkg/api/handlers/compat/containers.go | 17 ++++++++++++++--- test/apiv2/20-containers.at | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/pkg/api/handlers/compat/containers.go b/pkg/api/handlers/compat/containers.go index 6eb9092061..596248e43b 100644 --- a/pkg/api/handlers/compat/containers.go +++ b/pkg/api/handlers/compat/containers.go @@ -463,9 +463,20 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*container.InspectResp state.Running = true } - // Dockers created state is our configured state - if state.Status == define.ContainerStateCreated.String() { - state.Status = define.ContainerStateConfigured.String() + // map our statuses to Docker's statuses + switch state.Status { + case define.ContainerStateConfigured.String(), define.ContainerStateCreated.String(): + state.Status = "created" + case define.ContainerStateRunning.String(), define.ContainerStateStopping.String(): + state.Status = "running" + case define.ContainerStatePaused.String(): + state.Status = "paused" + case define.ContainerStateRemoving.String(): + state.Status = "removing" + case define.ContainerStateStopped.String(), define.ContainerStateExited.String(): + state.Status = "exited" + default: + state.Status = "" // unknown state } if l.HasHealthCheck() && state.Status != "created" { diff --git a/test/apiv2/20-containers.at b/test/apiv2/20-containers.at index 3dce2367b5..94ff485050 100644 --- a/test/apiv2/20-containers.at +++ b/test/apiv2/20-containers.at @@ -698,7 +698,7 @@ t GET containers/status-test/json 200 .State.Status="running" podman stop status-test & sleep 1 -t GET containers/status-test/json 200 .State.Status="stopping" +t GET containers/status-test/json 200 .State.Status="running" sleep 3 t GET containers/status-test/json 200 .State.Status="exited" From c39fd061f0a85ad5cc15ac2e09d545ab55e11cf5 Mon Sep 17 00:00:00 2001 From: Patrick Barrett Date: Tue, 20 May 2025 09:32:18 -0500 Subject: [PATCH 2/2] fix CONTRIBUTING to say reference issue number 'or' url Signed-off-by: Patrick Barrett --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e2a8d7c603..484b1c7dd1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -236,7 +236,7 @@ It’s important to describe the change in plain English for the reviewer to ver Solve only one problem per patch. If your description starts to get long, that’s a sign that you probably need to split up your patch. -If the patch fixes a logged bug entry, refer to that bug entry by number and URL. +If the patch fixes a logged bug entry, refer to that bug entry by number or URL. If the patch follows from a mailing list discussion, give a URL to the mailing list archive. Please format these lines as `Fixes:` followed by the URL or, for Github bugs, the bug number preceded by a #. For example: