Quota charges attached volumes twice since 4.22.1 (cumulative + per-VM usage_volume records from #11531)

Đang mở
#14,550 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
22/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
backend, database

Hướng nghiên cứu

The double charge comes from two usage_volume helper rows per attached volume, one with vm_id NULL and one with vm_id set, which each produce a usage_type = 6 record in cloud_usage. Start by reproducing the row counts in usage_volume, cloud_usage and quota_usage after a Usage run, then trace how #11531 introduced the per-VM row. Done means each attached volume is billed once per hour, and the choice of which record kind Quota bills is settled with the maintainers first.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

problem

Since #11531 (4.22.1), Usage intentionally writes two kinds of usage_volume helper rows for an attached volume: a cumulative row (vm_id NULL) and a per-VM row (vm_id set). Both generate an hourly usage_type = 6 (VOLUME) record in cloud_usage, one with and one without vm_instance_id.

The Quota plugin treats both records as billable, so every attached volume is charged twice.

versions
  • CloudStack 4.22.1.1 (management, usage)
  • KVM, Ceph RBD primary storage
  • Quota enabled with a volume tariff (usage_type = 6)
steps to reproduce
  1. Enable Quota and configure a tariff for usage type 6.
  2. Create a data volume and attach it to a running VM (events VOLUME.CREATE, then VOLUME.ATTACH).
  3. After the next Usage run, check cloud_usage.usage_volume. There are two rows with deleted IS NULL, one with vm_id NULL and one with vm_id set to the VM.
  4. Check cloud_usage.cloud_usage for that volume and hour. There are two usage_type = 6 records with the same raw_usage: one with vm_instance_id NULL and one with vm_instance_id set.
  5. Check cloud_usage.quota_usage. There is one row per cloud_usage record, both with the same quota_used, so the account balance is debited twice.

Example, one volume and one hour:

cloud_usage.vm_instance_id records quota_used
NULL (cumulative) 1 0.0081
set (per-VM) 1 0.0081
expected

A volume should be charged once per hour. Quota should bill only one of the two record kinds, for example the cumulative record (vm_instance_id NULL), since that is the one that is consistent with pre-#11531 behaviour.

notes
  • Today, root volumes on new VMs don't show the double charge, because the second usage_volume insert fails on the old (volume_id, created) unique key (#13909 / #13933). Once that key is widened in 4.22.2, root volumes will get both rows too, and will also be double-charged by Quota.
  • Our workaround: an hourly job sets deleted = created on per-VM usage_volume rows whenever an active cumulative row exists for the same volume. Per-VM records then stop being generated for that volume, and the cumulative row keeps billing it through detach and re-attach. Records written before we found this had to be removed by hand.
Ngôn ngữ chính
Java
Star
3.1k
Fork
1.4k
Merge trung bình
9 ngày 23 giờ
Pull request đã merge (30 ngày)
19

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/cloudstack

Tất cả issue của apache/cloudstack

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.