-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 stop --filter id=abc : 'abc' should match only at start #18471
Comments
The code calls: Your test could be changed to "^76bcb.*" I think. |
Playing around with docker, it looks like it does not use regex at all. |
More likelye HasPrefix( |
Slightly related: remote filters are quite broken (see #18412) |
Well if we change to match Docker behavior we have a breaking change. I think it best to fix the test and just let it be. |
It's broken one way or another, but backwards compat is certainly a challenge. |
Well broken, if you don't give it enough specificity. |
Going back to my initial report... let's say I have these two containers:
Then let's say I type I humbly submit that stopping both containers violates POLA. I realize it's impossible to know if anyone has ever intentionally done
|
I agree, Ed. Short IDs have always been prefixes not sub-strings. |
I guess I take the blame for the regex part: 4f427a8 I rather not break podman users. Interestingly enough if you use
|
That's a tough one. I see it as a bug but if users would depend on this very behavior - which we for sure can never know - they'd break. |
I humbly submit that we do not care. This is a serious POLA violation, and the future cost of keeping the current behavior is higher than the cost of breaking anyone who does match-the-middle-of-a-SHA. |
I am leaning towards @edsantiago here. Users could accidentally do bad things like |
I disagree, the docs say the id filter accepts regex. We never know if users rely on that. This affects all |
Using regex on a semi random string, makes little sense. You would need to search all images ids for a pattern and then match on it. which eliminates the need for a filter I agree on regex for meaningful patterns, I don't see how it makes sense for random patterns. Another way of saying this would be there is nothing |
"accepts regex", to me, means "ACCEPTS", as in, "if I see a dot, asterisk, bracket, or other character suggesting a regular expression is desired, I will interpret it as such". "Accepts" does not, to my mind, automatically mean "defaults to". IOW Seriously, this is very important to me. There is no human being alive who has a script that does "podman ps -q | select some random middle characters from the CID | podman ... --filter". If there is such a person or script, there is something very wrong with their brain. OTOH this will bite us: a human being will some day type, or write a script, that filters on Yeah, what Dan said. |
Sure I get your point but what is POLA here? |
Good question. I would expect podman to match both. If I, as a human, see two CIDs in the output, I would immediately see that both begin with |
I am surprised that @edsantiago even found the conflict. Current behaviour is very difficult to figure out what happened. podman rm --filter=a Could remove my objects with the current design. |
I am not even sure we are consistant on our id filters.
Image id filter looks like you need a complete match. |
Flake just triggered again. Yes, it's easy to amend the test to use an anchored regex, but that is the wrong thing to do. |
I think a compromise would be to use prefix match if input is a valid ID (e.g. hex chars only). And then only use regex when is contains non hex chars. This would only break someone if they do a match in the middle but as you point out this isn't very likely. |
Wait - we're talking |
|
duh, sorry. I shouldn't do drive-by comments on my days off. Can anyone see any use case for regex matching? it can't possibly be automated. IMHO it's not worth the effort of adding regex logic when |
I agree in principle that it is not really useful. However it is around for a long time and even documented so changing it could break people. While there is little reason to do it it doesn't mean nobody does it. People do weird things all the time, e.g. me adding regex for ids in the first place. And a valid use case may be people who run into an issue like you and then worked around it by doing |
Sounds like a plan. Check the id first for any non hex characters, if yes then use regex check, if no do HasPrefix() |
For filter=id=XXX (containers, pods) and =ctr-ids=XXX (pods): if XXX is only hex characters, treat it as a PREFIX otherwise, treat it as a REGEX Add tests. Update documentation. And fix an incorrect help message. Fixes: containers#18471 Signed-off-by: Ed Santiago <[email protected]>
By default we should do a standard prefix match. See containers/podman#18471 for context. Signed-off-by: Paul Holzinger <[email protected]>
By default we should do a standard prefix match. See containers/podman#18471 for context. Signed-off-by: Paul Holzinger <[email protected]>
By default we should do a standard prefix match. See containers/podman#18471 for context. Also use the c/storage regex package to only compile the regex when needed. Signed-off-by: Paul Holzinger <[email protected]>
By default we should do a standard prefix match. See containers/podman#18471 for context. Also use the c/storage regex package to only compile the regex when needed. Signed-off-by: Paul Holzinger <[email protected]>
We no longer allow to match ids in the middle, this makes no realy sense. ID matches should always be by prefix. containers#18471 Signed-off-by: Paul Holzinger <[email protected]>
An interesting new flake today, took me much too long to understand:
...test fails because it expected output to be
76bcb4b0b1cd7af97ada76bef9e803a74e5fe9e0a6ecd55d8dcd4e864fe3e72b
. Can you see why the test failed? How about now?Assumption: nobody is ever, ever, ever going to call
--filter id=SOMETHING-IN-THE-MIDDLE
.Proposal: make
--filter id=NNN
anchor at the beginning of the id.The text was updated successfully, but these errors were encountered: