From 2d861ac14ad5b677717f357bd57c3f56f06307d5 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Fri, 20 Nov 2020 10:47:00 -0500 Subject: Handle ps container created field as a time.Time In the current code we were translating the created time from a time.Time to a unix epoch, this was leading to a loss of precession, and some unexpected results where the sorting order of containers was misordered because of the precession loss. If we pass around created as time.Time, we do not loose the precission. Fixes: https://github.com/containers/podman/issues/8414 Signed-off-by: Daniel J Walsh --- pkg/domain/entities/container_ps.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'pkg/domain/entities') diff --git a/pkg/domain/entities/container_ps.go b/pkg/domain/entities/container_ps.go index ed40a37ab..b4e8446cb 100644 --- a/pkg/domain/entities/container_ps.go +++ b/pkg/domain/entities/container_ps.go @@ -3,6 +3,7 @@ package entities import ( "sort" "strings" + "time" "github.com/containers/podman/v2/pkg/ps/define" "github.com/cri-o/ocicni/pkg/ocicni" @@ -14,7 +15,7 @@ type ListContainer struct { // Container command Command []string // Container creation time - Created int64 + Created time.Time // Human readable container creation time. CreatedAt string // If container has exited/stopped @@ -137,7 +138,7 @@ func (a psSortedSize) Less(i, j int) bool { type PsSortedCreateTime struct{ SortListContainers } func (a PsSortedCreateTime) Less(i, j int) bool { - return a.SortListContainers[i].Created < a.SortListContainers[j].Created + return a.SortListContainers[i].Created.Before(a.SortListContainers[j].Created) } func SortPsOutput(sortBy string, psOutput SortListContainers) (SortListContainers, error) { -- cgit v1.2.3-54-g00ecf