Clean up backup references to their schedules when the schedules are deleted#12401
Clean up backup references to their schedules when the schedules are deleted#12401bernardodemarco wants to merge 3 commits intoapache:4.22from
Conversation
|
@blueorangutan package |
|
@bernardodemarco a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.22 #12401 +/- ##
=========================================
Coverage 17.60% 17.60%
- Complexity 15674 15676 +2
=========================================
Files 5918 5918
Lines 531727 531729 +2
Branches 65016 65017 +1
=========================================
+ Hits 93595 93619 +24
+ Misses 427570 427548 -22
Partials 10562 10562
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16319 |
There was a problem hiding this comment.
Pull request overview
This PR addresses the cleanup of orphaned backup schedule references in the cloud.backups table. When backup schedules are deleted, backups created from those schedules retain references to non-existent schedule IDs. The PR implements proper cleanup by setting backup_schedule_id to NULL before deleting schedules, and also removes unused code and database columns.
Changes:
- Implements cleanup of backup schedule references before schedule deletion
- Removes unused
backup_interval_typecolumn fromcloud.backupstable - Refactors backup schedule response creation from DAO layer to API layer
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql | Adds SQL to drop unused backup_interval_type column |
| engine/schema/src/main/java/org/apache/cloudstack/backup/dao/BackupScheduleDaoImpl.java | Implements cleanup logic in remove() method and removes unused response builder |
| engine/schema/src/main/java/org/apache/cloudstack/backup/dao/BackupScheduleDao.java | Removes unused interface methods |
| server/src/main/java/com/cloud/api/ApiDBUtils.java | Removes delegation method for backup schedule response creation |
| server/src/main/java/com/cloud/api/ApiResponseHelper.java | Moves backup schedule response creation logic from DAO to API layer |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
engine/schema/src/main/java/org/apache/cloudstack/backup/dao/BackupScheduleDaoImpl.java
Show resolved
Hide resolved
engine/schema/src/main/java/org/apache/cloudstack/backup/dao/BackupScheduleDaoImpl.java
Show resolved
Hide resolved
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
|
@bernardodemarco can you check if there any any conflicts. thanks. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
engine/schema/src/main/java/org/apache/cloudstack/backup/dao/BackupScheduleDaoImpl.java
Show resolved
Hide resolved
engine/schema/src/main/java/org/apache/cloudstack/backup/dao/BackupScheduleDaoImpl.java
Outdated
Show resolved
Hide resolved
020f31a to
e1009dd
Compare
|
@blueorangutan package |
|
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17015 |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✖️ debian ✔️ suse15. SL-JID 17023 |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17025 |
|
@blueorangutan test |
|
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-15578)
|
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
4250f65 to
9e3df76
Compare
|
@blueorangutan package |
|
@bernardodemarco a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Tonitzpp
left a comment
There was a problem hiding this comment.
@bernardodemarco, lgtm. Here are the tests that I've done.
Tests descriptions
- First, I created a virtual machine to perform the tests
- Assigned a backup offering with the dummy provider
- Set up an hourly backup schedule
- Checked in the database the backup schedule that was taken in the
cloud.backupstable
select * from backups \G
*************************** 1. row ***************************
id: 1
uuid: 90aacd9d-cd3c-4f1e-b05d-60039c5f2daf
vm_id: 3
external_id: dummy-external-id
type: FULL
size: 8589934592
protected_size: 8589934592
status: BackedUp
backup_offering_id: 1
account_id: 2
domain_id: 1
zone_id: 1
removed: NULL
date: 2026-04-08 17:13:59
backed_volumes: [{"uuid":"1aa850ba-f375-4b95-b0e5-ab53720b2033","type":"ROOT","size":8589934592,"path":"1aa850ba-f375-4b95-b0e5-ab53720b2033","deviceId":0,"diskOfferingId":"fe487456-99a4-41b1-8fdd-65f717985973"}]
backup_schedule_id: 2
name: test-2026-04-08T17:13:59+0000
description: NULL
1 row in set (0.000 sec)
- Via CMK, I used the
deleteBackupScheduleAPI to remove the backup schedule that had been created - After removing, I checked the
cloud.backupstable to check if thebackup_schedule_idfield have been changed
select * from backups \G
*************************** 1. row ***************************
id: 1
uuid: 90aacd9d-cd3c-4f1e-b05d-60039c5f2daf
vm_id: 3
external_id: dummy-external-id
type: FULL
size: 8589934592
protected_size: 8589934592
status: BackedUp
backup_offering_id: 1
account_id: 2
domain_id: 1
zone_id: 1
removed: NULL
date: 2026-04-08 17:13:59
backed_volumes: [{"uuid":"1aa850ba-f375-4b95-b0e5-ab53720b2033","type":"ROOT","size":8589934592,"path":"1aa850ba-f375-4b95-b0e5-ab53720b2033","deviceId":0,"diskOfferingId":"fe487456-99a4-41b1-8fdd-65f717985973"}]
backup_schedule_id: NULL
name: test-2026-04-08T17:13:59+0000
description: NULL
1 row in set (0.000 sec)
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17405 |
Description
Currently, the
cloud.backupstable references a backup schedule through thebackup_schedule_idfield. It is only populated when a backup is created from a schedule. For ad hoc backups, the field's value is kept asNULL.Additionally, when backup schedules are deleted via the
deleteBackupScheduleAPI, their corresponding entries are expunged from the DB. However, the backups' references to the schedules are not cleaned up and, thus, these references remain indefinitely in thecloud.backupstable. It is important to highlight that, although the clean up process is not performed, it does not cause any bugs/side effects.Therefore, this PR proposes to clean up such references before deleting backup schedules from the DB. The PR also cleans up some pieces of the code related with backup schedules, removing unused methods, moving methods' definitions to appropriate layers of the project and dropping the unused
backup_interval_typecolumn from thecloud.backupstable (see #11223).Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?