Skip to content

Test that deleting a volume releases its storage - #616

Open
Trenyx wants to merge 1 commit into
kernel:mainfrom
Trenyx:test/delete-volume-releases-storage
Open

Trenyx wants to merge 1 commit into
kernel:mainfrom
Trenyx:test/delete-volume-releases-storage

Conversation

@Trenyx

@Trenyx Trenyx commented Nov 26, 2026 •

Copy link
Copy Markdown

If DeleteVolume stopped taking a volume's size off the running total, Hypeman would keep counting deleted volumes as used disk until a restart: /resources and instance admission would see too little free disk, and creates under max_total_volume_storage would be refused although the space was freed. No test would notice.

Tests only: one test (+24 lines) in lib/volumes/manager_test.go. No change to library code.

TestDeleteVolume_ReleasesStorage creates a 1 GB volume, checks that TotalVolumeBytes reports it, deletes it, and checks that the total is back to 0. TotalVolumeBytes is documented as used by the resource manager for disk capacity tracking, and since #187 it is served from a cached total that create adds to and delete subtracts from.

How it was checked

On main at 2455387, go test -tags=containers_image_openpgp -count=1 ./lib/volumes ./lib/autostandby ./lib/imagepush ./lib/ocicachegc ./cmd/api/config passes (229 tests, on a GitHub-hosted ubuntu-latest runner, no KVM or root). With the m.subtractVolumeBytes(...) call removed from DeleteVolume, this new test is the only one that fails. gofmt and go vet are clean.

This test was written with Claude Code during a planted-bug run by Saurabh (SK) @ Trenyx.


Note

Low Risk
Test-only change with no runtime behavior impact.

Overview
Adds TestDeleteVolume_ReleasesStorage in lib/volumes/manager_test.go so coverage exists for disk accounting on delete.

The test creates a 1 GiB volume, checks that TotalVolumeBytes includes it, deletes the volume, and expects the total back at 0. That path matters because the cached total drives /resources and max_total_volume_storage admission; if DeleteVolume stopped calling subtractVolumeBytes, freed space would stay booked until restart.

Tests only — no production code changes.

Reviewed by Cursor Bugbot for commit d367bc1. Bugbot is set up for automated code reviews on this repo. Configure here.

DeleteVolume subtracts the volume's size from the cached total that
TotalVolumeBytes reports to disk capacity tracking, but no test checked
that the total goes back down after a delete.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant