Merge pull request #26149 from azdle/docker-api-container-status

compat: fix ContainerState.Status JSON values
This commit is contained in:
openshift-merge-bot[bot] 2025-05-20 17:53:12 +00:00 committed by GitHub
commit 5629ba8a8d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 5 deletions

View File

@ -236,7 +236,7 @@ Its 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, thats 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:

View File

@ -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" {

View File

@ -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"