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

Remove two GetImages functions from API #12572

Merged
merged 1 commit into from
Jan 15, 2022

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Dec 10, 2021

[NO NEW TESTS NEEDED] This is just code cleanup.

The remote API has three different GetImages functions, which I believe
can be handled by just one function.

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

What this PR does / why we need it:

How to verify it

Which issue(s) this PR fixes:

Special notes for your reviewer:

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 10, 2021
@rhatdan rhatdan force-pushed the image branch 2 times, most recently from 64a53ac to 66aef6f Compare December 10, 2021 15:24
@rhatdan
Copy link
Member Author

rhatdan commented Dec 10, 2021

@jwhonce @flouthoc Looks like their is something special in the Docker API for handling dangling images.

I went through the code to make sure libpod, docker-compat and local all use the same code paths.

podman --remote images -a
podman images -a
DOCKER_HOST=unix:///run/user/3267/podman/podman.sock docker images -a

Are all passing exactly the same params and back the same content, but podman lists the images but the docker client does not. Any ideas?

#12567

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.

Compatibility needs to be doubled checked, missing call that populated/formatted fields.


is, err := handlers.ImageToImageSummary(img)
Copy link
Member

Choose a reason for hiding this comment

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

By skipping the call to ImageToImageSummary:

  • ImageSummary.VirtualSize will be incorrect.
  • It appears ID will no longer be prefixed with sha256:
  • ImageSummary.RepoDigests will no longer be formatted rather the raw data will be returned.
  • ...

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 have fixed the sha256.
VirtualSize seems to be the same between the two calls. (It is always just size).
I switched libpod output for RepoDigests to match Dockers.
I did not see any others.

summaries := make([]*entities.ImageSummary, 0, len(images))
for _, img := range images {
// If the image is a manifest list, extract as much as we can.
if isML, _ := img.IsManifestList(r.Context()); isML {
Copy link
Collaborator

Choose a reason for hiding this comment

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

For compat api we were ignoring manifest list I think merging this with common code would start printing manifest lists as well.

I have only looked at the code yet. But I'll need to try this out inoder to make it sure that we are not breaking any existing behavior.

Copy link
Member Author

@rhatdan rhatdan Dec 22, 2021

Choose a reason for hiding this comment

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

This filter
filterList = append(filterList, "manifest=false")

Should remove all manifest images for the DockerAPI.

@rhatdan rhatdan changed the title Remove to GetImages functions from API [wip] Remove to GetImages functions from API Dec 13, 2021
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 13, 2021
@rhatdan rhatdan changed the title [wip] Remove to GetImages functions from API Remove to GetImages functions from API Dec 14, 2021
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 14, 2021
@flouthoc flouthoc linked an issue Dec 17, 2021 that may be closed by this pull request
@rhatdan rhatdan force-pushed the image branch 7 times, most recently from 01099cb to 8598899 Compare December 22, 2021 20:57
@rhatdan rhatdan added the breaking-change A change that will require a full version bump, i.e. 3.* to 4.* label Dec 22, 2021
@rhatdan
Copy link
Member Author

rhatdan commented Dec 27, 2021

@vrothberg PTAL at the error.
containers/common has changed the behavior of

mkdir -p /tmp/test
podman pull alpine
podman push alpine dir:/tmp/test/
podman rmi  alpine
podman pull dir:/tmp/test

In current podman we get an image named

podman images
localhost/tmp/test                 latest      c059bfaa849c  4 weeks ago   5.87 MB

With the latest containers/common we get

podman images
<none>                <none>      c059bfaa849c  4 weeks ago   5.87 MB

I think the second option looks correct, and we should fix the pull_test.go code, but want to verify with you.

@vrothberg
Copy link
Member

@rhatdan, I agree that the second one is correct. I should have check the tests in Podman and Buildah after it has merged. I will re-apply the PR in c/common and then open PRs in Podman/Buildah.

@rhatdan
Copy link
Member Author

rhatdan commented Jan 11, 2022

@containers/podman-maintainers PTAL
@vrothberg @flouthoc @giuseppe PTAL

Comment on lines 66 to 76
if !opts.All && !filterPrefix("dangling=", pruneOptions.Filters) {
pruneOptions.Filters = append(pruneOptions.Filters, "dangling=true")
}
if opts.External {
pruneOptions.Filters = append(pruneOptions.Filters, "containers=external")
} else {
pruneOptions.Filters = append(pruneOptions.Filters, "containers=false")
if !filterPrefix("containers=", pruneOptions.Filters) {
if opts.External {
pruneOptions.Filters = append(pruneOptions.Filters, "containers=external")
} else {
pruneOptions.Filters = append(pruneOptions.Filters, "containers=false")
}
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 this should be removed, @vrothberg correct?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Luap99 I think these are dangling images from multistage builds. I dont think API should return these. But I can check what docker is returning.

Copy link
Member

Choose a reason for hiding this comment

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

I mean the change should be removed, see containers/common@134e83f
@vrothberg fixed the problem in c/common so this is no longer needed

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah i see. Fair if that is fixed in upstream then check could be removed.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that's not needed anymore.

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

Besides @Luap99's nit LGTM. Less (redundant) code is always a great thing!

Comment on lines 66 to 76
if !opts.All && !filterPrefix("dangling=", pruneOptions.Filters) {
pruneOptions.Filters = append(pruneOptions.Filters, "dangling=true")
}
if opts.External {
pruneOptions.Filters = append(pruneOptions.Filters, "containers=external")
} else {
pruneOptions.Filters = append(pruneOptions.Filters, "containers=false")
if !filterPrefix("containers=", pruneOptions.Filters) {
if opts.External {
pruneOptions.Filters = append(pruneOptions.Filters, "containers=external")
} else {
pruneOptions.Filters = append(pruneOptions.Filters, "containers=false")
}
Copy link
Member

Choose a reason for hiding this comment

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

Yes, that's not needed anymore.

Comment on lines 66 to 63
if !opts.All && !filterPrefix("dangling=", pruneOptions.Filters) {
pruneOptions.Filters = append(pruneOptions.Filters, "dangling=true")
}
if opts.External {
if opts.External && !filterPrefix("containers=", pruneOptions.Filters) {
pruneOptions.Filters = append(pruneOptions.Filters, "containers=external")
} else {
pruneOptions.Filters = append(pruneOptions.Filters, "containers=false")
Copy link
Member

Choose a reason for hiding this comment

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

Please remove the change here and also remove the filterPrefix function above

Copy link
Member Author

Choose a reason for hiding this comment

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

We are blocking double duplicate filters. So if it has containers=external from some were else, then we don't want to add it again.

Copy link
Member

Choose a reason for hiding this comment

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

@vrothberg fixed this in c/common see the comments above, you have to rebase this to get the latest common

@TomSweeneyRedHat
Copy link
Member

Could you touch up the title plase @rhatdan? I think you meant "two", not "to".

@rhatdan rhatdan changed the title Remove to GetImages functions from API Remove two GetImages functions from API Jan 12, 2022
@rhatdan rhatdan force-pushed the image branch 2 times, most recently from a759ee4 to c3d779d Compare January 12, 2022 20:02
@@ -55,16 +64,19 @@ func (ir *ImageEngine) Prune(ctx context.Context, opts entities.ImagePruneOption
}

if !opts.All {
pruneOptions.Filters = append(pruneOptions.Filters, "dangling=true")
if !filterPrefix("dangling=", pruneOptions.Filters) {
Copy link
Collaborator

@flouthoc flouthoc Jan 14, 2022

Choose a reason for hiding this comment

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

This the same check where @Luap99 raised concern before. If this is handled by c/common then we might not need it. But I don't think there is any blocker if we are checking for duplicates.

so LGTM

Copy link
Collaborator

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.

Yes, the dangling-logic can/should be removed.

Copy link
Member Author

Choose a reason for hiding this comment

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

The dangling check is looking for dupicates. This function can be called in multiple different ways. And certain code paths and Remote API can pass in a filter with dangling=true already set, which ends up adding the dangling=true, which I am trying to prevent. If you are suggesting the common defaults to dangling=true?

Copy link
Member

Choose a reason for hiding this comment

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

The code in question was added to work around the duplicate checks in c/common. In the meantime, c/common accepts duplicates as long as they use the same value, so we don't need the custom check here anymore.

Copy link
Collaborator

@flouthoc flouthoc 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
Copy link
Contributor

openshift-ci bot commented Jan 14, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc, rhatdan

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

@flouthoc
Copy link
Collaborator

/hold till @vrothberg @Luap99 confirm.

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 14, 2022
[NO NEW TESTS NEEDED] This is just code cleanup.

The remote API has three different GetImages functions, which I believe
can be handled by just one function.

Signed-off-by: Daniel J Walsh <[email protected]>
@rhatdan
Copy link
Member Author

rhatdan commented Jan 15, 2022

@vrothberg @Luap99 Mergeme.

@Luap99
Copy link
Member

Luap99 commented Jan 15, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 15, 2022
@rhatdan
Copy link
Member Author

rhatdan commented Jan 15, 2022

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 15, 2022
@openshift-merge-robot openshift-merge-robot merged commit 3c9e41b into containers:main Jan 15, 2022
@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 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 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. breaking-change A change that will require a full version bump, i.e. 3.* to 4.* 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.

Listing images with docker client only shows tagged images
7 participants