diff options
author | Matthew Heon <matthew.heon@pm.me> | 2022-09-12 09:28:58 -0400 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2022-09-12 16:43:24 -0400 |
commit | 07a8eb829563df9215d86eed7b3337c14dadb6cc (patch) | |
tree | 6fda6b6d6c98b4d4ffd39b3a24355ada043b426e /test/apiv2 | |
parent | 94864cbce6e758552c853999951681bfdef93b18 (diff) | |
download | podman-07a8eb829563df9215d86eed7b3337c14dadb6cc.tar.gz podman-07a8eb829563df9215d86eed7b3337c14dadb6cc.tar.bz2 podman-07a8eb829563df9215d86eed7b3337c14dadb6cc.zip |
Ensure that the DF endpoint updated volume refcount
The field was already exposed already in the `system df` output
so this just required a bit of plumbing and testing.
As part of this, fix `podman systemd df` volume in-use logic.
Previously, volumes were only considered to be in use if the
container using them was running. This does not match Docker's
behavior, where a volume is considered in use as long as a
container exists that uses the volume, even if said container is
not running.
Fixes #15720
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'test/apiv2')
-rw-r--r-- | test/apiv2/45-system.at | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/apiv2/45-system.at b/test/apiv2/45-system.at index 364b87c56..096df5516 100644 --- a/test/apiv2/45-system.at +++ b/test/apiv2/45-system.at @@ -25,6 +25,24 @@ t GET system/df 200 '.Volumes[0].Name=foo1' t GET libpod/system/df 200 '.Volumes[0].VolumeName=foo1' +# Verify that no containers reference the volume +t GET system/df 200 '.Volumes[0].UsageData.RefCount=0' + +# Make a container using the volume +podman pull $IMAGE &>/dev/null +t POST containers/create Image=$IMAGE Volumes='{"/test":{}}' HostConfig='{"Binds":["foo1:/test"]}' 201 \ + .Id~[0-9a-f]\\{64\\} +cid=$(jq -r '.Id' <<<"$output") + +# Verify that one container references the volume +t GET system/df 200 '.Volumes[0].UsageData.RefCount=1' + +# Remove the container +t DELETE containers/$cid?v=true 204 + +# Verify that no containers reference the volume +t GET system/df 200 '.Volumes[0].UsageData.RefCount=0' + # Create two more volumes to test pruneing t POST libpod/volumes/create \ Name=foo2 \ |