Issue Description
Multiple filtering in volume prune/ls command doesn't work as intuitively expected. I assumed that adding more filters would reduce a number of entities. Filters are combined with OR operator instead of AND. Probably, the same issue was resolved for images in release v5.0.0 (#18412).
Steps to reproduce the issue
- Create a test script.
# test_volume_prune.sh
#!/bin/bash -x
podman volume create --label a=b podman-test-1
podman volume create --label c=d podman-test-2
podman volume create --label a=b --label c=d podman-test-3
sleep 6
podman volume create --label a=b podman-test-1-new
podman volume create --label c=d podman-test-2-new
podman volume create --label a=b --label c=d podman-test-3-new
podman volume ls -q
podman volume ls -q --filter "label=a=b"
podman volume ls -q --filter "label!=c=d"
podman volume ls -q --filter until="5s"
podman volume ls -q --filter "label=a=b" --filter "label!=c=d"
podman volume ls -q --filter "label!=c=d" --filter "label=a=b"
podman volume ls -q --filter "label=a=b" --filter until="5s"
podman volume ls -q --filter "label!=c=d" --filter until="5s"
podman volume ls -q --filter "label=a=b" --filter "label!=c=d" --filter until="5s"
podman volume prune -f --filter "label=a=b" --filter "label!=c=d" --filter until="5s"
# podman system prune -f --volumes --filter "label=a=b" --filter "label!=c=d" --filter until="5s"
podman volume ls -q
- Run
test_volume_prune.sh.
Describe the results you received
$ ./test_volume_prune.sh
+ podman volume create --label a=b podman-test-1
podman-test-1
+ podman volume create --label c=d podman-test-2
podman-test-2
+ podman volume create --label a=b --label c=d podman-test-3
podman-test-3
+ sleep 6
+ podman volume create --label a=b podman-test-1-new
podman-test-1-new
+ podman volume create --label c=d podman-test-2-new
podman-test-2-new
+ podman volume create --label a=b --label c=d podman-test-3-new
podman-test-3-new
+ podman volume ls -q
podman-test-1
podman-test-2
podman-test-3
podman-test-1-new
podman-test-2-new
podman-test-3-new
+ podman volume ls -q --filter label=a=b
podman-test-1
podman-test-3
podman-test-1-new
podman-test-3-new
+ podman volume ls -q --filter 'label!=c=d'
podman-test-1
podman-test-1-new
+ podman volume ls -q --filter until=5s
podman-test-1
podman-test-2
podman-test-3
+ podman volume ls -q --filter label=a=b --filter 'label!=c=d'
podman-test-1
podman-test-3
podman-test-1-new
podman-test-3-new
# label="a=b" OR "label!=c=d"
+ podman volume ls -q --filter 'label!=c=d' --filter label=a=b
podman-test-1
podman-test-3
podman-test-1-new
podman-test-3-new
# an order of filters doesn't matter
+ podman volume ls -q --filter label=a=b --filter until=5s
podman-test-1
podman-test-2
podman-test-3
podman-test-1-new
podman-test-3-new
# label="a=b" OR until=5s
+ podman volume ls -q --filter 'label!=c=d' --filter until=5s
podman-test-1
podman-test-2
podman-test-3
podman-test-1-new
# "label!=c=d" OR until=5s
+ podman volume ls -q --filter label=a=b --filter 'label!=c=d' --filter until=5s
podman-test-1
podman-test-2
podman-test-3
podman-test-1-new
podman-test-3-new
+ podman volume prune -f --filter label=a=b --filter 'label!=c=d' --filter until=5s
podman-test-1
podman-test-2
podman-test-3
podman-test-1-new
podman-test-3-new
# `podman system prune -f --volumes` behaves the same way
+ podman volume ls -q
podman-test-2-new
Describe the results you expected
$ ./test_volume_prune.sh
+ podman volume create --label a=b podman-test-1
podman-test-1
+ podman volume create --label c=d podman-test-2
podman-test-2
+ podman volume create --label a=b --label c=d podman-test-3
podman-test-3
+ sleep 6
+ podman volume create --label a=b podman-test-1-new
podman-test-1-new
+ podman volume create --label c=d podman-test-2-new
podman-test-2-new
+ podman volume create --label a=b --label c=d podman-test-3-new
podman-test-3-new
+ podman volume ls -q
podman-test-1
podman-test-2
podman-test-3
podman-test-1-new
podman-test-2-new
podman-test-3-new
+ podman volume ls -q --filter label=a=b
podman-test-1
podman-test-3
podman-test-1-new
podman-test-3-new
+ podman volume ls -q --filter 'label!=c=d'
podman-test-1
podman-test-1-new
+ podman volume ls -q --filter until=5s
podman-test-1
podman-test-2
podman-test-3
+ podman volume ls -q --filter label=a=b --filter 'label!=c=d'
podman-test-1
podman-test-1-new
+ podman volume ls -q --filter 'label!=c=d' --filter label=a=b
podman-test-1
podman-test-1-new
+ podman volume ls -q --filter label=a=b --filter until=5s
podman-test-1
podman-test-3
+ podman volume ls -q --filter 'label!=c=d' --filter until=5s
podman-test-1
+ podman volume ls -q --filter label=a=b --filter 'label!=c=d' --filter until=5s
podman-test-1
+ podman volume prune -f --filter label=a=b --filter 'label!=c=d' --filter until=5s
podman-test-1
+ podman volume ls -q
podman-test-2
podman-test-3
podman-test-1-new
podman-test-2-new
podman-test-3-new
podman info output
$ podman version
Client: Podman Engine
Version: 4.9.4-rhel
API Version: 4.9.4-rhel
Go Version: go1.21.7 (Red Hat 1.21.7-1.el9)
Built: Tue Apr 30 18:53:26 2024
OS/Arch: linux/amd64
$ podman info
host:
arch: amd64
buildahVersion: 1.33.7
cgroupControllers:
- cpu
- io
- memory
- pids
cgroupManager: systemd
cgroupVersion: v2
conmon:
package: conmon-2.1.10-1.el9.x86_64
path: /usr/bin/conmon
version: 'conmon version 2.1.10, commit: 574ce145d4fde456322f648afc2cb9dc2141ee16'
cpuUtilization:
idlePercent: 87.48
systemPercent: 0.49
userPercent: 12.02
cpus: 128
databaseBackend: sqlite
distribution:
distribution: almalinux
version: "9.4"
eventLogger: file
freeLocks: 2045
hostname: <...>
idMappings:
gidmap:
- container_id: 0
host_id: 31
size: 1
- container_id: 1
host_id: <...>
size: 65536
uidmap:
- container_id: 0
host_id: <...>
size: 1
- container_id: 1
host_id: <...>
size: 65536
kernel: 5.14.0-427.13.1.el9_4.x86_64
linkmode: dynamic
logDriver: k8s-file
memFree: 41125249024
memTotal: 540135604224
networkBackend: netavark
networkBackendInfo:
backend: netavark
dns:
package: aardvark-dns-1.10.0-3.el9_4.x86_64
path: /usr/libexec/podman/aardvark-dns
version: aardvark-dns 1.10.0
package: netavark-1.10.3-1.el9.x86_64
path: /usr/libexec/podman/netavark
version: netavark 1.10.3
ociRuntime:
name: crun
package: crun-1.14.3-1.el9.x86_64
path: /usr/bin/crun
version: |-
crun version 1.14.3
commit: 1961d211ba98f532ea52d2e80f4c20359f241a98
rundir: /run/user/10056539/crun
spec: 1.0.0
+SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
os: linux
pasta:
executable: /usr/bin/pasta
package: passt-0^20231204.gb86afe3-1.el9.x86_64
version: |
pasta 0^20231204.gb86afe3-1.el9.x86_64
Copyright Red Hat
GNU General Public License, version 2 or later
<https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
remoteSocket:
exists: true
path: /run/user/<...>/podman.sock
security:
apparmorEnabled: false
capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
rootless: true
seccompEnabled: true
seccompProfilePath: /usr/share/containers/seccomp.json
selinuxEnabled: false
serviceIsRemote: false
slirp4netns:
executable: /usr/bin/slirp4netns
package: slirp4netns-1.2.3-1.el9.x86_64
version: |-
slirp4netns version 1.2.3
commit: c22fde291bb35b354e6ca44d13be181c76a0a432
libslirp: 4.4.0
SLIRP_CONFIG_VERSION_MAX: 3
libseccomp: 2.5.2
swapFree: 274806861824
swapTotal: 274877902848
uptime: 194h 9m 17.00s (Approximately 8.08 days)
variant: ""
plugins:
authorization: null
log:
- k8s-file
- none
- passthrough
- journald
network:
- bridge
- macvlan
- ipvlan
volume:
- local
registries:
search:
- registry.access.redhat.com
- registry.redhat.io
- docker.io
store:
configFile: /<...>/storage.conf
containerStore:
number: 2
paused: 0
running: 1
stopped: 1
graphDriverName: overlay
graphOptions:
overlay.mount_program:
Executable: /usr/bin/fuse-overlayfs
Package: fuse-overlayfs-1.13-1.el9.x86_64
Version: |-
fusermount3 version: 3.10.2
fuse-overlayfs: version 1.13-dev
FUSE library version 3.10.2
using FUSE kernel interface version 7.31
graphRoot: /SCRATCH/.../storage
graphRootAllocated: 7619770974208
graphRootUsed: 1991168380928
graphStatus:
Backing Filesystem: extfs
Native Overlay Diff: "false"
Supports d_type: "true"
Supports shifting: "true"
Supports volatile: "true"
Using metacopy: "false"
imageCopyTmpDir: /var/tmp
imageStore:
number: 3
runRoot: /SCRATCH/semenov/run
transientStore: false
volumePath: /SCRATCH/.../volumes
version:
APIVersion: 4.9.4-rhel
Built: 1714528406
BuiltTime: Tue Apr 30 18:53:26 2024
GitCommit: ""
GoVersion: go1.21.7 (Red Hat 1.21.7-1.el9)
Os: linux
OsArch: linux/amd64
Version: 4.9.4-rhel
$ rpm -q podman
podman-4.9.4-3.el9_4.x86_64
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
No
Additional environment details
I have checked fresh podman v5.5.2 inside container of mgoltzsche/podman:5 (sha256:435750f07968663e88ecc35947a8430735963540a2d6b857140691c05bc3422c) and haven't seen difference.
Additional information
Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting
Issue Description
Multiple filtering in
volume prune/lscommand doesn't work as intuitively expected. I assumed that adding more filters would reduce a number of entities. Filters are combined withORoperator instead ofAND. Probably, the same issue was resolved for images in release v5.0.0 (#18412).Steps to reproduce the issue
test_volume_prune.sh.Describe the results you received
Describe the results you expected
podman info output
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
No
Additional environment details
I have checked fresh podman v5.5.2 inside container of
mgoltzsche/podman:5(sha256:435750f07968663e88ecc35947a8430735963540a2d6b857140691c05bc3422c) and haven't seen difference.Additional information
Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting