Skip to content

c8d/list: Implement reference#45269

Merged
thaJeztah merged 1 commit intomoby:masterfrom
vvoland:c8d-reference-filter
Apr 6, 2023
Merged

c8d/list: Implement reference#45269
thaJeztah merged 1 commit intomoby:masterfrom
vvoland:c8d-reference-filter

Conversation

@vvoland
Copy link
Contributor

@vvoland vvoland commented Apr 4, 2023

- What I did
Implemented reference filter.
Note: The fork implementation used fuzzy match for reference filter, but this isn't consistent with the graphdriver Docker.

- How I did it

- How to verify it

$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED              SIZE
alpine       latest    124c7d270790   About a minute ago   3.27MB
busybox      latest    b5d6fe071263   2 seconds ago        2.01MB
$ docker images --filter 'reference=busybox'
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
busybox      latest    b5d6fe071263   8 seconds ago   2.01MB
$ docker images busybox
REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
busybox      latest    b5d6fe071263   10 seconds ago   2.01MB
$ docker images alpine
REPOSITORY   TAG       IMAGE ID       CREATED              SIZE
alpine       latest    124c7d270790   About a minute ago   3.27MB

- Description for the changelog

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

@vvoland vvoland added status/2-code-review area/images Image Distribution containerd-integration Issues and PRs related to containerd integration labels Apr 4, 2023
@vvoland vvoland added this to the 24.0.0 milestone Apr 4, 2023
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM (left some suggestions, but no blockers)

@@ -254,8 +255,9 @@ type imageFilterFunc func(image images.Image) bool
// setupFilters constructs an imageFilterFunc from the given imageFilters.
//
// TODO(thaJeztah): reimplement filters using containerd filters: see https://github.com/moby/moby/issues/43845
Copy link
Member

Choose a reason for hiding this comment

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

Are there (more) filters we can delegate to containerd? (Otherwise we could remove this comment) - not a blocker though we can always remove in a follow-up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, dangling can be done with c8d too.
Not sure about time and how c8d would compare them. Will check.

Copy link
Member

Choose a reason for hiding this comment

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

Let's keep the ticket open then (feel free to leave a comment there on other filters we could still implement using containerd to improve things)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah currently we can't do any more (except dangling). Posted a code that specified available properties in the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Crap, dangling is fun too. There's no fuzzy negation, so we'd need something like this: https://github.com/moby/moby/blob/master/.github/workflows/buildkit.yml#L123 😅

Copy link
Member

Choose a reason for hiding this comment

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

😬 yeah, let's not do that for now 😂

//
// TODO(thaJeztah): reimplement filters using containerd filters: see https://github.com/moby/moby/issues/43845
func (i *ImageService) setupFilters(ctx context.Context, imageFilters filters.Args) (imageFilterFunc, error) {
func (i *ImageService) setupFilters(ctx context.Context, imageFilters filters.Args) ([]string, imageFilterFunc, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Not a blocker (as it's not exported), but we could consider to use either named return variables (to "document" what they are), or update the GoDoc of the function to describe what it returns.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed parameters to be named and described them in Godoc.

@vvoland vvoland force-pushed the c8d-reference-filter branch from 61d4383 to 8ab18ae Compare April 4, 2023 16:49
@vvoland vvoland mentioned this pull request Apr 4, 2023
thaJeztah
thaJeztah previously approved these changes Apr 4, 2023
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@rumpl rumpl left a comment

Choose a reason for hiding this comment

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

LGTM after the fix for the equals operator

@vvoland vvoland force-pushed the c8d-reference-filter branch from 8ab18ae to d24bc42 Compare April 5, 2023 10:09
@vvoland
Copy link
Contributor Author

vvoland commented Apr 5, 2023

Hmm wait, isn't the fork behavior for label wrong?
It checks the labels on containerd Image object, not Labels from the image Config.

@vvoland
Copy link
Contributor Author

vvoland commented Apr 5, 2023

For example, Ubuntu:

$ docker inspect ubuntu -f '{{.Config.Labels}}'
map[org.opencontainers.image.ref.name:ubuntu org.opencontainers.image.version:22.04]

This is on "non-c8d Docker":

$ docker images --filter label=org.opencontainers.image.ref.name
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
ubuntu       latest    bab8ce5c00ca   4 weeks ago   69.2MB

But it won't have the same result with this implementation because ubuntu image doesn't have these labels attached to the containerd image object (labels are empty):

$ ctr image ls
REF                              TYPE                                                      DIGEST                                                                  SIZE     PLATFORMS                                                                                                                          LABELS   
docker.io/library/ubuntu:latest  application/vnd.oci.image.index.v1+json                   sha256:67211c14fa74f070d27cc59d69a7fa9aeff8e28ea118ef3babc295a0428a6d21 26.1 MiB linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x                                                                  -        

So, unless we want to populate containerd Image object's Labels with the labels from Config, we can't use containerd filter for this one.

@vvoland vvoland requested review from rumpl and thaJeztah April 5, 2023 10:26
@vvoland vvoland force-pushed the c8d-reference-filter branch from d24bc42 to 9b6249a Compare April 5, 2023 15:17
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@vvoland vvoland force-pushed the c8d-reference-filter branch from 9b6249a to ba47cdc Compare April 6, 2023 11:45
@vvoland vvoland changed the title c8d/list: Implement reference and label! filter c8d/list: Implement reference Apr 6, 2023
@vvoland
Copy link
Contributor Author

vvoland commented Apr 6, 2023

Moved the label filter out of this PR as it's not a simple upstream PR as it initially was supposed to be.

@vvoland vvoland dismissed thaJeztah’s stale review April 6, 2023 15:31

Code changed from last LGTM

@vvoland vvoland requested a review from thaJeztah April 6, 2023 15:31
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@thaJeztah thaJeztah merged commit 79bf167 into moby:master Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/images Image Distribution containerd-integration Issues and PRs related to containerd integration status/2-code-review

Projects

Development

Successfully merging this pull request may close these issues.

containerd integration: implement "reference" filter for images

3 participants