apache / apache/cloudstack

VM Backup usage billed at last-reported size for the entire billing period

オープン
#13,070 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
component:backup component:usage-server
主要言語
Java
スター
3.1k
フォーク
1.4k
平均マージ
6日 19時間
マージ済み PR(30日)
32

説明

### problem

When `EVENT_VM_BACKUP_USAGE_METRIC` events are processed, `Usage Manager` performs an in-place UPDATE of the single usage_backup row for a given (vm_id, backup_offering_id) pair. This means only the most recently received size is retained. When BackupUsageParser runs at billing time, it reads that single row and applies its size to the entire billing window duration, regardless of when the size actually changed.

### versions

ACS 4.20

### The steps to reproduce the bug

The problem is independent of the provider but I am using NAS for testing:
1. Set usage.stats.job.exec.time to `10:00`
2. Assign a backup offering to a VM at `11:00`
3. Create a backup of size 1GB at `11:00`
4. Create a backup of size 99GB at `09:00` the next day
5. Wait for usage job to run and finish at `10:00`

### What to do about it?

**Expected Behavior**
The user should be charged proportionally: ~23 hours at 1 GB + ~1 hours at 100 GB

**Actual Behavior**
The user is charged at 100 GB for the full 24 hours because the last metric event overwrote the size column in-place, erasing all history.

**Fix would be to:**

- Find the active row in `usage_backup` (removed IS NULL) for the (vm_id, backup_offering_id).
- Set its removed = eventDate.
- persist a new UsageBackupVO with the updated size/protectedSize and created = eventDate.
- This matches the existing pattern in UsageNetworksDaoImpl and UsageVpcDaoImpl.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Usage Manager による EVENT_VM_BACKUP_USAGE_METRIC の処理から始め、usage_backup 行が BackupUsageParser によってどのように処理されるかを追跡します。UsageNetworksDaoImpl と UsageVpcDaoImpl の既存のパターンを比較し、サイズの変更によって履歴区間が作成され、課金で各サイズについてアクティブだった期間に対してのみ請求されることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
backend, cloud
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
72/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。