summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-05-04 15:39:44 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-05-05 11:48:06 +0000
commit0906b3094d192427524dc8652de23f4e7acbcfd1 (patch)
treecb68640fb4de998e459d1c4d85cc238c372adf87 /cmd
parentbb0e7540dcdcd77747418658058767c2705ad0a0 (diff)
downloadpodman-0906b3094d192427524dc8652de23f4e7acbcfd1.tar.gz
podman-0906b3094d192427524dc8652de23f4e7acbcfd1.tar.bz2
podman-0906b3094d192427524dc8652de23f4e7acbcfd1.zip
Fix calculation of RunningFor in ps json output
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #727 Approved by: rhatdan
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/ps.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go
index 907c437b6..a0b6f134b 100644
--- a/cmd/podman/ps.go
+++ b/cmd/podman/ps.go
@@ -395,7 +395,7 @@ func getTemplateOutput(containers []*libpod.Container, opts batchcontainer.PsOpt
runningFor := ""
// If the container has not be started, the "zero" value of time is 0001-01-01 00:00:00 +0000 UTC
// which would make the time elapsed about a few hundred of years. So checking for the "zero" value of time.Time
- if batchInfo.StartedTime != (time.Time{}) {
+ if !batchInfo.StartedTime.IsZero() {
runningFor = units.HumanDuration(time.Since(batchInfo.StartedTime))
}
createdAt := batchInfo.ConConfig.CreatedTime.Format("2006-01-02 15:04:05 -0700 MST")
@@ -495,7 +495,6 @@ func getJSONOutput(containers []*libpod.Container, opts batchcontainer.PsOptions
ImageID: batchInfo.ConConfig.RootfsImageID,
Command: batchInfo.ConConfig.Spec.Process.Args,
CreatedAt: batchInfo.ConConfig.CreatedTime,
- RunningFor: time.Since(batchInfo.ConConfig.CreatedTime),
Status: batchInfo.ConState.String(),
Ports: batchInfo.ConConfig.PortMappings,
RootFsSize: batchInfo.RootFsSize,
@@ -506,6 +505,11 @@ func getJSONOutput(containers []*libpod.Container, opts batchcontainer.PsOptions
ContainerRunning: batchInfo.ConState == libpod.ContainerStateRunning,
Namespaces: ns,
}
+
+ if !batchInfo.StartedTime.IsZero() {
+ params.RunningFor = time.Since(batchInfo.StartedTime)
+ }
+
psOutput = append(psOutput, params)
}
return psOutput, nil