You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bucket usage continues even after the bucket is deleted. #13057
I've identified a potential bug in the CloudStack usage section. After deleting a bucket, I noticed that the cloudstack.listUsageRecords API call was still reporting usage of the deleted buckets for the accounts.
I started exploring the code and how this bucket usage system works, and I found that it all depends on the bucket_statistics table.
From what I understand and replicate in my tests, when a bucket is removed, the bucket_statistics table retains the used size value. In my understanding, the correct approach would be to reset this value or delete the record for that bucket in this table. I corrected this in the accounts by resetting the size value, thus stopping the generation of new records in the cloud_usage table.
If you have any further questions, feel free to ask and I'll provide more details.
Thank you.
versions
Cloudstack 4.22
The steps to reproduce the bug
Create a bucket
Add data to the bucket
Wait a few days for cloud_usage records to be generated
Remove the data from the bucket
Then remove the bucket from Cloudstack
Verify in the listUsageRecords API calls that usage records are still being generated for the bucket.
What to do about it?
When removing a bucket, the bucket_statistics table retains the used size value; in my understanding, the correct approach would be to reset this value or delete the record for that bucket in this table.
This issue is stale because it has been open for 120 days with no activity. It may be removed by administrators of this project at any time. Remove the stale label or comment to request for removal of it to prevent this.
Related failure observed on CloudStack 4.22.1.1: when a type-29 usage record references a bucket that is absent even from findByIdIncludingRemoved, listUsageRecords returns HTTP 530 instead of returning the usage response.
The exception is Cannot invoke "com.cloud.storage.BucketVO.getUuid()" because "bucket" is null.
ApiResponseHelper.java in 4.22.1.1 dereferences the lookup result through getUuid() and getName() without a null check. The same branch remains in current main, checked on 2026-09-15.
This adds a response-handling failure to the stale-statistics problem described here. Normal soft deletion alone does not explain a lookup returning null. The cause of the missing bucket row in our case remains unknown.
Suggested regression case: a BUCKET usage record whose bucket lookup returns null, included in an otherwise valid usage response. The API should handle the missing resource without failing the entire response. This is a proposed test, not a new reproduction run.
Stopping the orphaned statistics source and clearing only the affected usage backlog restored the API in our environment. Subsequent completed aggregation runs did not recreate the orphaned usage. No upstream patch has been applied; the missing-resource guard still needs a fix independently of statistics cleanup.
Activity
boring-cyborg commentedon Apr 22, 2026
Thanks for opening your first issue here! Be sure to follow the issue template!
andrijapanicsb commentedon Apr 23, 2026
Sounds like a bug...
DaanHoogland commentedon Apr 28, 2026
@rodrigues8 did you see a bucket delete event in the usage_event table?
rodrigues8 commentedon Apr 30, 2026
There are no bucket records in usage_events; it seems the method for checking bucket usage is different from compute offers.
Only the bucket_statistics table is taken into consideration. @DaanHoogland
DaanHoogland commentedon May 1, 2026
@abh1sar can you give your opinion on this one, please?
abh1sar commentedon May 13, 2026
Yes, this does look like a bug. bucket_statistics entry should be removed when a bucket is deleted
github-actions commentedon Sep 11, 2026
This issue is stale because it has been open for 120 days with no activity. It may be removed by administrators of this project at any time. Remove the stale label or comment to request for removal of it to prevent this.
ditahkk commentedon Sep 15, 2026
Related failure observed on CloudStack 4.22.1.1: when a type-29 usage record references a bucket that is absent even from
findByIdIncludingRemoved,listUsageRecordsreturns HTTP 530 instead of returning the usage response.The exception is
Cannot invoke "com.cloud.storage.BucketVO.getUuid()" because "bucket" is null.ApiResponseHelper.java in 4.22.1.1 dereferences the lookup result through
getUuid()andgetName()without a null check. The same branch remains in current main, checked on 2026-09-15.This adds a response-handling failure to the stale-statistics problem described here. Normal soft deletion alone does not explain a lookup returning null. The cause of the missing bucket row in our case remains unknown.
Suggested regression case: a BUCKET usage record whose bucket lookup returns null, included in an otherwise valid usage response. The API should handle the missing resource without failing the entire response. This is a proposed test, not a new reproduction run.
Stopping the orphaned statistics source and clearing only the affected usage backlog restored the API in our environment. Subsequent completed aggregation runs did not recreate the orphaned usage. No upstream patch has been applied; the missing-resource guard still needs a fix independently of statistics cleanup.