Skip to content

libimage: fix reference filters#1503

Merged
openshift-merge-robot merged 1 commit intocontainers:mainfrom
vrothberg:fix-podman-18445
Jun 14, 2023
Merged

libimage: fix reference filters#1503
openshift-merge-robot merged 1 commit intocontainers:mainfrom
vrothberg:fix-podman-18445

Conversation

@vrothberg
Copy link
Member

Make sure that reference filters properly work on digests as well. To keep things simple, try to lookup an image for the user-specified value and compare IDs. This will implicitly fix #containers/podman/issues/18445 and probably more (unknown) issues.

Fixes: #containers/podman/issues/18445

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 14, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vrothberg

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

The pull request process is described here

Details 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

Make sure that reference filters properly work on digests as well.
To keep things simple, try to lookup an image for the user-specified
value and compare IDs.  This will implicitly fix #containers/podman/issues/18445
and probably more (unknown) issues.

Fixes: #containers/podman/issues/18445
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
vrothberg added a commit to vrothberg/libpod that referenced this pull request Jun 14, 2023
[NO NEW TESTS NEEDED]

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
@vrothberg
Copy link
Member Author

Let's wait for containers/podman#18884 to turn green before merging. I want to be extra sure that the changes don't have any unintended side effect.

@vrothberg
Copy link
Member Author

All good. @Luap99 @rhatdan PTAL

@rhatdan
Copy link
Member

rhatdan commented Jun 14, 2023

LGTM

@Luap99
Copy link
Member

Luap99 commented Jun 14, 2023

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jun 14, 2023
@openshift-merge-robot openshift-merge-robot merged commit 93be4a8 into containers:main Jun 14, 2023
vrothberg pushed a commit to vrothberg/common that referenced this pull request Jun 15, 2023
libimage: fix reference filters
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
vrothberg pushed a commit to vrothberg/common that referenced this pull request Jun 15, 2023
libimage: fix reference filters
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
vrothberg pushed a commit to vrothberg/common that referenced this pull request Jun 15, 2023
libimage: fix reference filters
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
vrothberg pushed a commit to vrothberg/common that referenced this pull request Jun 15, 2023
libimage: fix reference filters
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
vrothberg pushed a commit to vrothberg/common that referenced this pull request Jun 15, 2023
libimage: fix reference filters
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
lookedUp, _, _ := r.LookupImage(value, nil)
return func(img *Image) (bool, error) {
if lookedUp != nil {
if lookedUp.ID() == img.ID() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems imprecise to me.

The code below seems fairly clear that fedora:38 is intended to match example.com/any/namespaces/fedora:38; and even that wildcards work, so fe*ra:38 is intended to match.

Is that correct?

If so, fe*ra@sha256:$digest should also match — but LookupImage can (I hope?) never resolve fe*ra.

IOW, if the underlying problem is that img.NamesReferences() does not contain digests, I think that needs to be solved directly here, not by relying on the LookupImage crutch (and on the lookupImageInDigestsAndRepoTags code path for matching short names) — maybe by combining img.NamesReference() with img.RepoDigests() when building candidates.

Now, RepoDigests is imprecise and relying on it would also introduce a weak variant of #1248 (where an image that exists on registry as repo1@digest1 and repo2@digest2 can be referenced using repo1@digest2, although that exists on no registry — but it’s a weaker variant because otherRepo@digest1 does not match). Ideally we should fix RepoDigests, but that’s a whole other set of PRs again.

Copy link
Contributor

Choose a reason for hiding this comment

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

Even more extreme, wildcards inside the digest? fedora@sha*:a?b*c ?

@vrothberg vrothberg deleted the fix-podman-18445 branch June 23, 2023 07:17
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.

5 participants