problem
Good afternoon everyone,
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.
problem
Good afternoon everyone,
I've identified a potential bug in the CloudStack usage section. After deleting a bucket, I noticed that the
cloudstack.listUsageRecordsAPI 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_statisticstable.From what I understand and replicate in my tests, when a bucket is removed, the
bucket_statisticstable 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 thecloud_usagetable.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
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.