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

[spike] remote filters #18412

Closed
vrothberg opened this issue May 2, 2023 · 14 comments · Fixed by #21260
Closed

[spike] remote filters #18412

vrothberg opened this issue May 2, 2023 · 14 comments · Fixed by #21260
Labels
5.0 locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@vrothberg
Copy link
Member

As described in #18345 (comment), Podman clients and Docker clients behave slightly different when it comes to passing filters over the REST API.

I did not fully investigate it but my currently feeling is that Podman clients do it wrong.

Image filters, for instance, can use a key=value or key syntax. Docker clients split the filter map as "{"label":["version=1.0"]} while Podman clients split the filter map as "{"label":["version","1.0"]}. For the latter, I don't think we can distinguish a key=value from a key if more than one filter of the same type (e.g., label) are specified.

@github-actions
Copy link

github-actions bot commented Jun 7, 2023

A friendly reminder that this issue had no activity for 30 days.

@rhatdan
Copy link
Member

rhatdan commented Jun 7, 2023

@edsantiago @Luap99 are working on this correct?

@edsantiago
Copy link
Member

Not to my knowledge.

@Luap99
Copy link
Member

Luap99 commented Jun 7, 2023

No

@rhatdan
Copy link
Member

rhatdan commented Jun 7, 2023

Oops, my tired eyes read this as the problem with filtering .HasPrefix, verus ContainsString for ID matching.

@github-actions
Copy link

github-actions bot commented Aug 8, 2023

A friendly reminder that this issue had no activity for 30 days.

@rhatdan
Copy link
Member

rhatdan commented Aug 9, 2023

This has been approved correct?

@vrothberg
Copy link
Member Author

This has been approved correct?

I don't think anybody has worked on it yet. At the moment, it remains unclear what needs to be done and how much of a problem it is.

@rhatdan
Copy link
Member

rhatdan commented Aug 9, 2023

s/approved/improved/g
I thought we only match on the prefix now, not anywhere in the id?

@vrothberg
Copy link
Member Author

Image filters, for instance, can use a key=value or key syntax. Docker clients split the filter map as "{"label":["version=1.0"]} while Podman clients split the filter map as "{"label":["version","1.0"]}. For the latter, I don't think we can distinguish a key=value from a key if more than one filter of the same type (e.g., label) are specified.

I think this problem persists. At least I am unaware of a fix.

@umohnani8
Copy link
Member

Looked into this a bit and when more than one filter is passed, docker does an AND operation where if the image matches all the given filters, only then will it be in the final result. While podman seems to do an OR operation where if any image matches any of the filters given, it will be in the final result. This is the case for both local and remote.

We did a similar fix for volumes here #19219, I think images should follow suit and match the behavior. @rhatdan @vrothberg WDYT?

@vrothberg
Copy link
Member Author

@umohnani8 I think that's orthogonal to the issue here.

Image filters, for instance, can use a key=value or key syntax. Docker clients split the filter map as "{"label":["version=1.0"]} while Podman clients split the filter map as "{"label":["version","1.0"]}. For the latter, I don't think we can distinguish a key=value from a key if more than one filter of the same type (e.g., label) are specified.

Filters can be in the format of key=value or key. But Podman's REST API doesn't seem to be able to distinguish that correctly.

@umohnani8
Copy link
Member

umohnani8 commented Jan 2, 2024

@vrothberg can you please give me an example? I have tried both the remote and local cases and I see the AND vs OR issue for the filters given for the local case. The remote case has another problem where if you pass it two --filter flags it only filters on the last filter passed.
So for example, podman images --filter label=foo=bar --filter label=test=bar will only return images that match the test=bar case.

When I just do podman images --filter label=foo, I get all the images that have the key foo even if they have a value assigned to it and when I do podman images --filter label=foo=bar, I only get the images that have foo=bar set as a label. Same results with podman --remote.
Looking at the podman filter parsing code here https://github.com/containers/podman/blob/main/vendor/github.com/containers/common/pkg/filters/filters.go#L81, it creates a final filter array of the format "["foo=bar", test=bar]. I am not able to trigger the issue defined here.

@vrothberg
Copy link
Member Author

For the AND vs OR, I´d prefer breaking that out into a separate issue.

For the filter issue, look at the linked issue and the old PR:
https://github.com/containers/podman/pull/18345/files

This should highlight the differences. The way Podman works does not allow for discriminating label=foo=bar from label=foo+label=bar. So this needs fixing but it's a breaking change (in some way). Hence the 5.0 label.

@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 Apr 28, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
5.0 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 a pull request may close this issue.

5 participants