Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

podman ps --sort created : not always sorting by created #8414

Closed
edsantiago opened this issue Nov 19, 2020 · 0 comments · Fixed by #8427
Closed

podman ps --sort created : not always sorting by created #8414

edsantiago opened this issue Nov 19, 2020 · 0 comments · Fixed by #8427
Labels
locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@edsantiago
Copy link
Member

About one in five tries, this gives me the wrong (unexpected) result:

$ img=quay.io/libpod/testimage:20200929
$ ./bin/podman run -d --name c1 $img true;./bin/podman run -d --name c2 $img true;./bin/podman ps -a --sort created
faf3c3ebd4c764dad41ecee6ae0aafb077ef0ae9181f03c05235c8445de779fa
a381df699c40d4a46f4a678b2758154af375bcb1aee445526171afbf3d9f6e76
CONTAINER ID  IMAGE                              COMMAND  CREATED       STATUS                             PORTS   NAMES
a381df699c40  quay.io/libpod/testimage:20200929  true     1 second ago  Exited (0) Less than a second ago          c2
faf3c3ebd4c7  quay.io/libpod/testimage:20200929  true     1 second ago  Exited (0) 1 second ago                    c1

I expect to see c1 before c2, always. It's not a timing issue with -d, because c1.Created < c2.Created:

$ ./bin/podman inspect --format '{{.Name}} {{.Created}}' c1 c2
c1 2020-11-19 13:30:14.806452 -0700 MST
c2 2020-11-19 13:30:14.948358079 -0700 MST

It's not a flake in ps, because for any given run of two containers, podman ps -a --sort created will always return the same order, always always, at least for values of "always" less than a ten-minute while loop.

In every instance when I see this, the CID of c2 is lexically < CID(c1); so much so that it seems improbable (many tens of repeated runs). I don't know if this is helpful. The sorting code looks good to my eye:

func (a PsSortedCreateTime) Less(i, j int) bool {
return a.SortListContainers[i].Created < a.SortListContainers[j].Created
}

I don't know where else to look; am hoping that someone can take a quick look at the sorting code and see something obvious.

rhatdan added a commit to rhatdan/podman that referenced this issue Nov 20, 2020
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: containers#8414

Signed-off-by: Daniel J Walsh <[email protected]>
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant