summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorumohnani8 <umohnani@redhat.com>2018-01-23 13:34:22 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-01-25 02:57:40 +0000
commit4c7bab9812b95fed8e6f8255b51b843b3e762782 (patch)
treec31105dbf83cf5f53d04ae27e26190d6ee48e5e4
parent49576a1fb107eb691cee9757465f060817702d43 (diff)
downloadpodman-4c7bab9812b95fed8e6f8255b51b843b3e762782.tar.gz
podman-4c7bab9812b95fed8e6f8255b51b843b3e762782.tar.bz2
podman-4c7bab9812b95fed8e6f8255b51b843b3e762782.zip
Fixed Created At and Running For value
Changed the Created At value to match the format of docker ps and fixed the value for Running For to reflect the time elapsed since the container has been started. Initially it was showing the time elapsed since the container was created. Signed-off-by: umohnani8 <umohnani@redhat.com> Closes: #257 Approved by: rhatdan
-rw-r--r--cmd/podman/ps.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go
index be6c5aef5..0b75b9a96 100644
--- a/cmd/podman/ps.go
+++ b/cmd/podman/ps.go
@@ -427,9 +427,17 @@ func getTemplateOutput(containers []*libpod.Container, opts psOptions) ([]psTemp
if batchErr != nil {
return nil, err
}
-
- runningFor := units.HumanDuration(time.Since(conConfig.CreatedTime))
- createdAt := runningFor + " ago"
+ runningFor := ""
+ startedTime, err := ctr.StartedTime()
+ if err != nil {
+ logrus.Errorf("error getting started time for %q: %v", ctr.ID(), err)
+ }
+ // 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 startedTime != (time.Time{}) {
+ runningFor = units.HumanDuration(time.Since(startedTime))
+ }
+ createdAt := conConfig.CreatedTime.Format("2006-01-02 15:04:05 -0700 MST")
imageName := conConfig.RootfsImageName
rootFsSize, err := ctr.RootFsSize()
if err != nil {