diff options
author | Matthew Heon <mheon@redhat.com> | 2018-07-13 11:21:37 -0400 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2018-07-13 14:28:41 -0400 |
commit | 4c44185199299f44425ebd689bf3ac42e4606788 (patch) | |
tree | b11dd559505e2bcedc266e0ad7ae5d75b32f3334 /cmd/podman/ps.go | |
parent | d25ebcc35bc59ac536eacf59af978181e6adabd3 (diff) | |
download | podman-4c44185199299f44425ebd689bf3ac42e4606788.tar.gz podman-4c44185199299f44425ebd689bf3ac42e4606788.tar.bz2 podman-4c44185199299f44425ebd689bf3ac42e4606788.zip |
Major fixes to podman ps --format=json output
A number of fields were never being populated. Populate them as
best we can.
Add a new field, exited, to indicate whether the exit code has
meaning (IE, the container has exited).
Fix handling of running time - it stops ticking when the
container stops. There is further work needed here, I suspect.
Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'cmd/podman/ps.go')
-rw-r--r-- | cmd/podman/ps.go | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go index a5f417449..b659a91a0 100644 --- a/cmd/podman/ps.go +++ b/cmd/podman/ps.go @@ -58,6 +58,7 @@ type psJSONParams struct { Command []string `json:"command"` CreatedAt time.Time `json:"createdAt"` ExitCode int32 `json:"exitCode"` + Exited bool `json:"exited"` RunningFor time.Duration `json:"runningFor"` Status string `json:"status"` PID int `json:"PID"` @@ -576,22 +577,26 @@ func getAndSortJSONParams(containers []*libpod.Container, opts batchcontainer.Ps ns = batchcontainer.GetNamespaces(batchInfo.Pid) } params := psJSONParams{ - ID: ctr.ID(), - Image: batchInfo.ConConfig.RootfsImageName, - ImageID: batchInfo.ConConfig.RootfsImageID, - Command: batchInfo.ConConfig.Spec.Process.Args, - CreatedAt: batchInfo.ConConfig.CreatedTime, - Status: batchInfo.ConState.String(), - Ports: batchInfo.ConConfig.PortMappings, - RootFsSize: batchInfo.RootFsSize, - RWSize: batchInfo.RwSize, - Names: batchInfo.ConConfig.Name, - Labels: batchInfo.ConConfig.Labels, - Mounts: batchInfo.ConConfig.UserVolumes, - Namespaces: ns, + ID: ctr.ID(), + Image: batchInfo.ConConfig.RootfsImageName, + ImageID: batchInfo.ConConfig.RootfsImageID, + Command: batchInfo.ConConfig.Spec.Process.Args, + CreatedAt: batchInfo.ConConfig.CreatedTime, + ExitCode: batchInfo.ExitCode, + Exited: batchInfo.Exited, + Status: batchInfo.ConState.String(), + PID: batchInfo.Pid, + Ports: batchInfo.ConConfig.PortMappings, + RootFsSize: batchInfo.RootFsSize, + RWSize: batchInfo.RwSize, + Names: batchInfo.ConConfig.Name, + Labels: batchInfo.ConConfig.Labels, + Mounts: batchInfo.ConConfig.UserVolumes, + ContainerRunning: batchInfo.ConState == libpod.ContainerStateRunning, + Namespaces: ns, } - if !batchInfo.StartedTime.IsZero() { + if !batchInfo.StartedTime.IsZero() && batchInfo.ConState == libpod.ContainerStateRunning { params.RunningFor = time.Since(batchInfo.StartedTime) } |