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
平均合并
6 天 19 小时
30 天内合并 PR
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 开始,跟踪 BackupUsageParser 如何处理 usage_backup 行。比较 UsageNetworksDaoImpl 和 UsageVpcDaoImpl 中现有的模式,然后验证大小变化会创建历史时间区间,从而使计费仅针对每种大小处于活动状态的时间收费。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
backend, cloud
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
冷清
描述清晰度
描述清楚
新手友好度
72/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。