mirror of https://github.com/containers/podman.git
Docker compat returning unknown "initialized" for `status.status`
Some background for this PR is in discussion #14641. In short, ever so often a container inspect will return a `status.status` of `initialized` from the Docker compat socket. From the discussion I found these lines which tries to fix a "configured" status to "created".c936d1e611/pkg/api/handlers/compat/containers.go (L291-L294)However, commit141de86862(Revamp Libpod state strings for Docker compat) removed the "configured" return value from the `String()` method called on line 291 above. Thus, making the `if` check redundant as it will never hit. But the same commit also introduces a return for "initialized" which this `if` should probably have been adapted for. Signed-off-by: Pieter Engelbrecht <pieter@shuttle.rs>
This commit is contained in:
parent
2382955c6a
commit
cc49146332
|
|
@ -289,8 +289,10 @@ func LibpodToContainer(l *libpod.Container, sz bool) (*handlers.Container, error
|
|||
return nil, err
|
||||
}
|
||||
stateStr := state.String()
|
||||
if stateStr == "configured" {
|
||||
stateStr = "created"
|
||||
|
||||
// Some docker states are not the same as ours. This makes sure the state string stays true to the Docker API
|
||||
if state == define.ContainerStateCreated {
|
||||
stateStr = define.ContainerStateConfigured.String()
|
||||
}
|
||||
|
||||
switch state {
|
||||
|
|
@ -420,9 +422,9 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON,
|
|||
state.Running = true
|
||||
}
|
||||
|
||||
// docker calls the configured state "created"
|
||||
if state.Status == define.ContainerStateConfigured.String() {
|
||||
state.Status = define.ContainerStateCreated.String()
|
||||
// Dockers created state is our configured state
|
||||
if state.Status == define.ContainerStateCreated.String() {
|
||||
state.Status = define.ContainerStateConfigured.String()
|
||||
}
|
||||
|
||||
if l.HasHealthCheck() && state.Status != "created" {
|
||||
|
|
|
|||
|
|
@ -502,3 +502,27 @@ done
|
|||
|
||||
stop_service
|
||||
start_service
|
||||
|
||||
# Our states are different from Docker's.
|
||||
# Regression test for #14700 (Docker compat returning unknown "initialized" for status.status) to ensure the stay compatible
|
||||
podman create --name status-test $IMAGE sh -c "sleep 3"
|
||||
t GET containers/status-test/json 200 .State.Status="created"
|
||||
|
||||
podman init status-test
|
||||
t GET containers/status-test/json 200 .State.Status="created"
|
||||
|
||||
podman start status-test
|
||||
t GET containers/status-test/json 200 .State.Status="running"
|
||||
|
||||
podman pause status-test
|
||||
t GET containers/status-test/json 200 .State.Status="paused"
|
||||
|
||||
podman unpause status-test
|
||||
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"
|
||||
|
||||
sleep 3
|
||||
t GET containers/status-test/json 200 .State.Status="exited"
|
||||
|
|
|
|||
Loading…
Reference in New Issue