Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Clean up backup references to their schedules when the schedules are deleted #12401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bernardodemarco wants to merge 2 commits into apache:4.22
base: 4.22
Choose a base branch
Loading
from scclouds:clean-backup-schedule-reference

Conversation

@bernardodemarco
Copy link
Member

@bernardodemarco bernardodemarco commented Jan 9, 2026
edited
Loading

Description

Currently, the cloud.backups table references a backup schedule through the backup_schedule_id field. It is only populated when a backup is created from a schedule. For ad hoc backups, the field's value is kept as NULL.

Additionally, when backup schedules are deleted via the deleteBackupSchedule API, 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 the cloud.backups table. 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_type column from the cloud.backups table (see #11223).

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

  1. Created a backup schedule and waited for some backups to be created from it
  2. Deleted the backup schedule
  3. Verified that the schedule's backups did not have references pointing to the schedule anymore

@bernardodemarco bernardodemarco added this to the 4.22.1 milestone Jan 9, 2026
Copy link
Member Author

@blueorangutan package

Copy link

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

Copy link

codecov bot commented Jan 9, 2026
edited
Loading

Codecov Report

❌ Patch coverage is 0% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.59%. Comparing base (04875f1) to head (020f31a).

Files with missing lines Patch % Lines
...src/main/java/com/cloud/api/ApiResponseHelper.java 0.00% 14 Missing ⚠️
...e/cloudstack/backup/dao/BackupScheduleDaoImpl.java 0.00% 10 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@
## 4.22 #12401 +/- ##
=========================================
 Coverage 17.59% 17.59% 
- Complexity 15599 15600 +1 
=========================================
 Files 5910 5910 
 Lines 529733 529734 +1 
 Branches 64719 64720 +1 
=========================================
+ Hits 93215 93218 +3 
+ Misses 426025 426024 -1 
+ Partials 10493 10492 -1 
Flag Coverage Δ
uitests 3.57% <ø> (ø)
unittests 18.66% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16319

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_type column from cloud.backups table
  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot Copilot left review comments

@abh1sar abh1sar Awaiting requested review from abh1sar

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

4.22.1

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /