apache / apache/cloudstack

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

未關閉
#13,070 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
component:backup component:usage-server
主要語言
Java
星號
3.1k
分支
1.4k
平均合併
7 天 14 小時
30 天內合併 PR
31

描述

### 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 開始,追蹤 BackupUsageParser 如何處理 usage_backup 列。比較 UsageNetworksDaoImpl 和 UsageVpcDaoImpl 中現有的模式,然後驗證大小變更會建立歷史時間區間,讓計費僅針對每種大小處於啟用狀態的時間收費。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
java
領域
backend, cloud
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
冷清
描述清晰度
描述清楚
新手友好度
72/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。