Repository navigation
Backport (#13936): quota: skip usage records registering the period a volume has been attached - #14612
Open
Daniel-Pereira-Linux wants to merge 1 commit into
Conversation
…tached (apache#13936) (cherry picked from commit ba67a62)
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR backports #13936 to 4.22, targeting 4.22.2.
Since #11531 (4.22.1), Usage writes two
usage_volumehelper rows for an attached volume: the cumulative row (vm_idNULL) and a per-VM row. Each one generates ausage_type = 6record, and Quota bills both, so attached volumes are charged twice. #13936 makes Quota ignore the per-VM records (VOLUME withvm_instance_idset): they are marked as calculated, and noquota_usagerow is created for them.It is a clean cherry-pick (
-x) of ba67a62. The only conflict was inQuotaManagerImplTest: 4.22 does not haveQuotaTariffUsageDao, so only theConfigDepotImplmock was kept.This matters more for 4.22.2: #13933 (already in 4.22) widened the unique key of
usage_volume, so ROOT volumes now get the per-VM row too. Without this backport, 4.22.2 would also bill ROOT volumes twice.Fixes: #14550
Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
Unit tests (JDK 21):
framework/quotawith checkstyle (123 tests),plugins/database/quota(76) andusage(21), all passing. Without the fix,shouldCalculateUsageRecordTestQuotaIsEnabledForAccountAndUsageRecordIsVolumeWithVmInstanceIdReturnFalsefails.End to end, on a lab with a management server and a nested KVM host (Rocky 9), using the official 4.22.1.1 packages, a 5-minute aggregation range and a VOLUME tariff. I compared
cloud_usagewithquota_usagerecord by record:cloud-framework-quotajar in the Usage server: per-VM records are no longer billed, and the cumulative record is billed once. RUNNING_VM is still billed.schema-42210to42220.sql(management server still on 4.22.1.1). The ROOT volume now gets the per-VM row and is billed once.Also checked:
quota_calculated = 1, so they are not picked up again.quotaStatementandquota_balancematch the sum of the cumulative records only.Not tested: VMware, XenServer and multiple management servers.
How did you try to break this feature and the system with this change?
Notes
@winterhazel, about existing records: on an unmodified 4.22.1.1 install I did get duplicates for data disks. The old unique key (
volume_id,created) only collides for ROOT volumes, where both rows share the samecreated. A data disk attached after it was created gets a per-VM row with the attach time, so it is inserted and billed. So 4.22.1.x environments that use Quota may already have duplicatedquota_usagerows for data disks. This PR does not change them. Do you think it is worth a note in the release notes?Also on 4.22.1.1, the ROOT per-VM insert fails with
Duplicate entry ... for key 'id'. The rollback leaves earlier events withprocessed = 0, so every job moves its start date back to the oldest event and parses old windows again. This is what #13933 fixes: after applying the new schema, the errors stopped and the jobs went back to consecutive windows. But the windows that were parsed again stay incloud_usage.