summaryrefslogtreecommitdiff
path: root/cmd/podman/batchcontainer
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-08-07 11:56:18 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-08 12:37:51 +0000
commit71793f9f8a26bc2593968f61a68c0bb42f9da71a (patch)
treeaad50ffe94dea6ab6256e17634bc698637454e42 /cmd/podman/batchcontainer
parent9e06478d8307b0279c991fd47122755fdf7bd922 (diff)
downloadpodman-71793f9f8a26bc2593968f61a68c0bb42f9da71a.tar.gz
podman-71793f9f8a26bc2593968f61a68c0bb42f9da71a.tar.bz2
podman-71793f9f8a26bc2593968f61a68c0bb42f9da71a.zip
Improve ps handling of container start/stop time
Previously all calculations were done based off the container's start time. Retrieve end time and use it to calculate time stopped for containers. Also, convert ps JSON output to report timestamps for create, start, and stop times. Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #1228 Approved by: rhatdan
Diffstat (limited to 'cmd/podman/batchcontainer')
-rw-r--r--cmd/podman/batchcontainer/container.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/cmd/podman/batchcontainer/container.go b/cmd/podman/batchcontainer/container.go
index de127c64d..e27914174 100644
--- a/cmd/podman/batchcontainer/container.go
+++ b/cmd/podman/batchcontainer/container.go
@@ -42,6 +42,7 @@ type BatchContainerStruct struct {
Exited bool
Pid int
StartedTime time.Time
+ ExitedTime time.Time
Size *ContainerSize
}
@@ -76,6 +77,7 @@ func BatchContainerOp(ctr *libpod.Container, opts PsOptions) (BatchContainerStru
pid int
size *ContainerSize
startedTime time.Time
+ exitedTime time.Time
)
batchErr := ctr.Batch(func(c *libpod.Container) error {
@@ -93,6 +95,10 @@ func BatchContainerOp(ctr *libpod.Container, opts PsOptions) (BatchContainerStru
if err != nil {
logrus.Errorf("error getting started time for %q: %v", c.ID(), err)
}
+ exitedTime, err = c.FinishedTime()
+ if err != nil {
+ logrus.Errorf("error getting exited time for %q: %v", c.ID(), err)
+ }
if !opts.Size && !opts.Namespace {
return nil
@@ -132,6 +138,7 @@ func BatchContainerOp(ctr *libpod.Container, opts PsOptions) (BatchContainerStru
Exited: exited,
Pid: pid,
StartedTime: startedTime,
+ ExitedTime: exitedTime,
Size: size,
}, nil
}