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 history now prints out intermediate image IDs #982

Closed
wants to merge 1 commit into from

Conversation

umohnani8
Copy link
Member

If the intermediate image exists in the store, podman history
will show the IDs of the intermediate image of each layer.

Fixes #980

Signed-off-by: umohnani8 [email protected]

@umohnani8
Copy link
Member Author

@rhatdan @mheon @edsantiago PTAL

@umohnani8
Copy link
Member Author

Example:

➜  libpod git:(history) sudo podman images -a
REPOSITORY                 TAG      IMAGE ID       CREATED             SIZE
localhost/test             latest   82bce1cc62b0   About an hour ago   4.42MB
<none>                     <none>   1f3d7455004e   About an hour ago   4.42MB
<none>                     <none>   848c7c10a9f4   About an hour ago   4.41MB
<none>                     <none>   4f9f31ad3500   About an hour ago   4.41MB
docker.io/library/fedora   latest   cc510acfcd70   6 weeks ago         263MB
docker.io/library/alpine   latest   3fd9065eaf02   5 months ago        4.41MB
➜  libpod git:(history) sudo podman history test
ID             CREATED             CREATED BY                                      SIZE      COMMENT
82bce1cc62b0   About an hour ago   /bin/sh -c touch test                           97B       
1f3d7455004e   About an hour ago   /bin/sh -c #(nop) COPY mount world/             6.656kB   
848c7c10a9f4   About an hour ago   /bin/sh -c touch /blah.txt                      1.536kB   
4f9f31ad3500   About an hour ago   /bin/sh -c mkdir /tmp/blah                      4.608kB   
3fd9065eaf02   5 months ago        /bin/sh -c #(nop) CMD ["/bin/sh"]               0B        
<none>         5 months ago        /bin/sh -c #(nop) ADD file:093f0723fa46f6c...   4.403MB   

Copy link
Member

@edsantiago edsantiago left a comment

Choose a reason for hiding this comment

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

LGTM but see minor query

imageID = imageIDs[imgIDCount]
imgIDCount++
} else {
imageID = "<none>"
Copy link
Member

Choose a reason for hiding this comment

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

For the sake of docker consistency, should this (and related changes) remain as <missing>?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, fixed. Not sure why I thought it was none...

@@ -609,7 +609,7 @@ func (i *Image) Layer() (*storage.Layer, error) {
}

// History gets the history of an image and information about its layers
func (i *Image) History(ctx context.Context) ([]ociv1.History, []types.BlobInfo, error) {
func (i *Image) History(ctx context.Context, imageIDs *[]string) ([]ociv1.History, []types.BlobInfo, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Why are we passing in imageIDs here? Can't we compute this from the image's own ID?

Copy link
Member

Choose a reason for hiding this comment

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

It seems like we should be returning imageIDs instead. Also, we should probably just return an array of one struct, containing the ociv1.History, types.BlobInfo, and image ID for the layer in history, so we don't have to worry about potentially mismatched array sizes.

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 want to pass in an array that I can modify, so that is why I was doing that. But you are right I can just return it instead. I am taking care of the size mismatch in cmd/podman/history.go.
Also we need to consider the order ocivi.History and types.BlobInfo are returned in. I think they are opposite of each other and this is also taken care of in cmd/podman/history.go.
Changing it one struct here will add more complexity, but if that is preferred I can make the change.

Copy link
Member

Choose a reason for hiding this comment

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

I think that returning one struct is probably better than returning sets of arrays that are potentially in reverse order... That seems really not-obvious to work with.

As a bonus, it might let us remove code duplication with varlink, which is always good.

Sorry for the extra work!

Copy link
Member Author

Choose a reason for hiding this comment

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

sure, no worries! Working on it.

return nil, nil, errors.Wrapf(err, "error getting images from store")
}
if err := i.historyLayerIDs(i.TopLayer(), images, imageIDs); err != nil {
return nil, nil, errors.Wrap(err, "error getting image IDs for layers in history")
Copy link
Member

Choose a reason for hiding this comment

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

nit two spaces before 'history'

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@umohnani8 umohnani8 force-pushed the history branch 2 times, most recently from f71ccd8 to ef5cd83 Compare June 22, 2018 14:33
@umohnani8
Copy link
Member Author

@mheon reworked it, PTAL

// History gets the history of an image and information about its layers
func (i *Image) History(ctx context.Context) ([]ociv1.History, []types.BlobInfo, error) {
func (i *Image) History(ctx context.Context) ([]History, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: can we return []*History instead, to avoid a copy?

@mheon
Copy link
Member

mheon commented Jun 22, 2018

LGTM. Thanks @umohnani8 - looks a lot cleaner now.

@rhatdan
Copy link
Member

rhatdan commented Jun 22, 2018

@rh-atomic-bot r+

@rh-atomic-bot
Copy link
Collaborator

📌 Commit ef5cd83 has been approved by rhatdan

@TomSweeneyRedHat
Copy link
Member

LGTM, especially if you can convert to a pointer per @mheon.

@umohnani8
Copy link
Member Author

@mheon can I still do it even though @rhatdan has started the commit bot? Last time it caused issues.

@mheon
Copy link
Member

mheon commented Jun 22, 2018

@umohnani8 I think if you push another commit it should cancel the merge, so you should be fine.

And the good news is that there are a good 4 or 5 PRs in line ahead of this one, so you have plenty of time

@TomSweeneyRedHat
Copy link
Member

@umohnani8 I would not change this PR unless it doesn't merge. I'd do a second PR after this one gets in.

@TomSweeneyRedHat
Copy link
Member

and always listen to @mheon over lucky-sweeney.

If the intermediate image exists in the store, podman history
will show the IDs of the intermediate image of each layer.

Signed-off-by: umohnani8 <[email protected]>
@umohnani8
Copy link
Member Author

@mheon should be fixed now. Thanks for the tip :)

@mheon
Copy link
Member

mheon commented Jun 22, 2018

@rh-atomic-bot r+

@rh-atomic-bot
Copy link
Collaborator

📌 Commit 18ebbfa has been approved by mheon

@rh-atomic-bot
Copy link
Collaborator

⌛ Testing commit 18ebbfa with merge 088d5af...

@rh-atomic-bot
Copy link
Collaborator

☀️ Test successful - status-papr
Approved by: mheon
Pushing 088d5af to master...

@umohnani8 umohnani8 deleted the history branch October 27, 2020 14:27
@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
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.

6 participants