-
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
Volume filtering works differently and misses existing label #8341
Comments
There is some bug in the filter construction, that butchers the options. for _, f := range cliOpts.Filter {
filterSplit := strings.Split(f, "=")
if len(filterSplit) < 2 {
return errors.Errorf("filter input must be in the form of filter=value: %s is invalid", f)
}
lsOpts.Filter[filterSplit[0]] = append(lsOpts.Filter[filterSplit[0]], filterSplit[1:]...)
} cliOpts.Filter [label=name.minikube.sigs.k8s.io=minikube] The bug is in GenerateVolumeFilters, in the loop construct. So instead of checking key=value, it checks the key twice instead: label name.minikube.sigs.k8s.io The filter switch needs to come before the value loop. for filter, v := range filters {
for _, val := range v {
switch filter { Otherwise it won't work for these label=key=value filters ?
It looks for a case "label":
filterArray := strings.SplitN(val, "=", 2) |
I think it was GenerateVolumeFilters that was right, when having multiple filters. So it was the command line flag parser that was too greedy, splitting every '=' |
It also seems that the logic in Volumes() filtering is broken. Currently it does an OR of the criteria, instead of an AND... if len(filters) == 0 {
return vols, nil
}
volsFiltered := make([]*Volume, 0, len(vols))
for _, vol := range vols {
include := false
for _, filter := range filters {
include = include || filter(vol)
}
if include {
volsFiltered = append(volsFiltered, vol)
}
}
return volsFiltered, nil So as long as the label matches, it will include every name:
But that's a different bug than this one, just found while testing... |
I think this is not a bug and expected. see: #8232 |
Okay, then it was just the example in the docs that was silly (not updated)...
|
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
Volume filtering works differently in podman, when compared to docker.
Steps to reproduce the issue:
minikube start --driver podman
sudo -n podman volume ls --filter label=name.minikube.sigs.k8s.io=minikube
Describe the results you received:
Describe the results you expected:
Additional information you deem important (e.g. issue happens only occasionally):
The --filter doesn't work with label:
minikube start --driver podman
It works OK with the docker driver.
minikube start --driver docker
Output of
podman version
:Output of
podman info --debug
:Package info (e.g. output of
rpm -q podman
orapt list podman
):Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide?
No
Additional environment details (AWS, VirtualBox, physical, etc.):
Ubuntu 20.04
The text was updated successfully, but these errors were encountered: