apache / apache/cloudstack

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

Abierto
#13,070 0 comentarios 0 reacciones 0 asignados Ver en GitHub
component:backup component:usage-server
Lenguaje dominante
Java
Estrellas
3.1k
Forks
1.4k
Merge medio
6 d 19 h
PR fusionados (30 d)
32

Descripción

### 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.

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza por el procesamiento de EVENT_VM_BACKUP_USAGE_METRIC por parte de Usage Manager y sigue cómo BackupUsageParser gestiona las filas usage_backup. Compara los patrones existentes en UsageNetworksDaoImpl y UsageVpcDaoImpl y verifica después que los cambios de tamaño crean intervalos históricos, de modo que la facturación cobre cada tamaño únicamente durante el tiempo en que estuvo activo.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
java
Área
backend, cloud
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Tranquilo
Claridad
Bien especificado
Aptitud para principiantes
72/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.