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

Handle ps container created field as a time.Time #8427

Merged
merged 1 commit into from
Dec 1, 2020

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented 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.

Fixes: #8414

If we pass around created as time.Time, we do not loose the precission.

Signed-off-by: Daniel J Walsh [email protected]

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]>
@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 20, 2020
@rhatdan
Copy link
Member Author

rhatdan commented Nov 20, 2020

@edsantiago PTAL

@@ -301,5 +301,5 @@ func (a SortPSContainers) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
type SortPSCreateTime struct{ SortPSContainers }

func (a SortPSCreateTime) Less(i, j int) bool {
return a.SortPSContainers[i].Created > a.SortPSContainers[j].Created
return a.SortPSContainers[i].Created.Before(a.SortPSContainers[j].Created)
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit confused. Was the ">" correct for the original version of this "Less()" function? If so, does this need to be After rather than Before, or are you correcting a bad sort?

Back to my tea cup.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

@jwhonce "I'm a mistake in original code", I wasn't aware you've gone full Tron in this project. That's a bit scary! 😄
Thx for the 411

@@ -14,7 +15,7 @@ type ListContainer struct {
// Container command
Command []string
// Container creation time
Created int64
Created time.Time
Copy link
Member

Choose a reason for hiding this comment

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

@rhatdan @jwhonce Is this going over the wire? As in, is this a breaking change to our JSON format?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't believe this is going over the wire. The time.Time came over the wire though.

Copy link
Member Author

Choose a reason for hiding this comment

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

But this may be a breaking change for anyone who has vendored in /pkg/ directories. So we might have to wait to fix this until 3.0.

Copy link
Member

@jwhonce jwhonce left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -301,5 +301,5 @@ func (a SortPSContainers) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
type SortPSCreateTime struct{ SortPSContainers }

func (a SortPSCreateTime) Less(i, j int) bool {
return a.SortPSContainers[i].Created > a.SortPSContainers[j].Created
return a.SortPSContainers[i].Created.Before(a.SortPSContainers[j].Created)
Copy link
Member

Choose a reason for hiding this comment

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

@TomSweeneyRedHat
Copy link
Member

LGTM
as long as @jwhonce is comfortable with the date type change.

@rhatdan
Copy link
Member Author

rhatdan commented Nov 20, 2020

@vrothberg Do you agree this is a breaking change, wait for 3.0>

@edsantiago
Copy link
Member

Well, the good news is, in one hour of loop testing I got no failures. LGTM.

BTW I have a test for it in the works, will submit PR some time later, possibly with a FIXME 8427 comment if this can't merge yet.

@rhatdan
Copy link
Member Author

rhatdan commented Nov 20, 2020

We are holding up the merge of this PR until after 2.2 release.

@rhatdan
Copy link
Member Author

rhatdan commented Dec 1, 2020

@containers/podman-maintainers PTAL This is ready to merge.

Copy link
Member

@saschagrunert saschagrunert left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 1, 2020
@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jwhonce, rhatdan, saschagrunert

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@baude
Copy link
Member

baude commented Dec 1, 2020

/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 1, 2020
@openshift-merge-robot openshift-merge-robot merged commit 2438390 into containers:master Dec 1, 2020
@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 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. 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 this pull request may close these issues.

podman ps --sort created : not always sorting by created
9 participants