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

Sort output of docker ps --filter with order by creation time #25387

Merged
merged 1 commit into from
Aug 5, 2016

Conversation

yongtang
Copy link
Member

@yongtang yongtang commented Aug 4, 2016

- What I did

This fix tries to address the issue raised in #25374 where the output of docker ps --filter is in random order and not deterministic.

- How I did it

This fix sorts the list of containers by creation time so that the output is deterministic.

- How to verify it

An integration test has been added.

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

This fix fixes #25374.

Signed-off-by: Yong Tang yong.tang.github@outlook.com

name4 := "789-123"
out, err = runSleepingContainer(c, "--name", name4)
c.Assert(err, checker.NotNil)
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need the above code from

name3 := "789-abc"
...
<above_line>

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhanghan177 the above is for the scenario where you have more containers overall than the filtered containers output (we are testing ps -f name=xyz in the following)

c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")

// Run multiple time should have the same result
out, err = dockerCmd(c, "ps", "-q", "-f", "name=xyz")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: perhaps add --no-trunc, and use the full ID's?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @thaJeztah! I forgot there is --no-trunc for docker ps.

@thaJeztah
Copy link
Member

Thanks @yongtang; left some comments/suggestions, but works good otherwise

This fix tries to address the issue raised in 25374 where the
output of `docker ps --filter` is in random order and
not deterministic.

This fix sorts the list of containers by creation time so that the
output is deterministic.

An integration test has been added.

This fix fixes 25374.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
@yongtang yongtang force-pushed the 25374-ps-filter-order branch from e75d2fe to 3f97133 Compare August 5, 2016 02:35
@yongtang
Copy link
Member Author

yongtang commented Aug 5, 2016

@thaJeztah The pull request has been updated. Please let me know if there are any issues.

@thaJeztah
Copy link
Member

Awesome! LGTM

ping @estesp @vdemeester PTAL

@vdemeester
Copy link
Member

LGTM 🐱

@vdemeester vdemeester merged commit 29fef34 into moby:master Aug 5, 2016
@thaJeztah thaJeztah added this to the 1.12.1 milestone Aug 5, 2016
@thaJeztah
Copy link
Member

Added this to the 1.12.1 milestone as this is a regression introduced in 1.12 (through #23084)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docker 1.12 ps filter result is non-deterministic
6 participants