-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Refactoring retention of backup schedules #11223
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
base: main
Are you sure you want to change the base?
Refactoring retention of backup schedules #11223
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #11223 +/- ##
============================================
- Coverage 16.58% 16.57% -0.01%
- Complexity 14038 14075 +37
============================================
Files 5758 5772 +14
Lines 511733 512910 +1177
Branches 62216 62305 +89
============================================
+ Hits 84871 85033 +162
- Misses 417389 418409 +1020
+ Partials 9473 9468 -5
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:
|
@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. |
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 14215 |
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
Description
PR #10017 introduced, among other features, the ability to configure retention for backup schedules. This PR aims to fix some minor inconsistencies in that feature, refactor redundant workflows and behaviors, and improve code readability and maintainability by adding logs and more granular unit tests.
Below, I have listed all the points that this PR addresses.
Exposed
scheduleid
parameterWhen scheduling a backup creation, the ID of the schedule responsible for the backup is passed as a parameter to the
createBackup
API:cloudstack/server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java
Lines 1307 to 1322 in f52e058
This parameter is intended solely for use by the scheduling workflow. End users should neither access nor be aware of it. If a backup is manually created while specifying a schedule ID, inconsistencies may occur later in the scheduling process. To prevent this, changes were made to ensure the parameter is not exposed to end users.
Relationship between
cloud.backup
andcloud.backup_schedule
To determine whether backups should be deleted to meet the retention requirements, the backup creation workflow must be able to identify whether the backup is scheduled and which schedule it belongs to. If the backup is scheduled, retention validation should be performed. On the other hand, if it is a manual backup, retention validation should be skipped.
Currently, the
cloud.backup
table uses thebackup_interval_type
column for this purpose:cloudstack/engine/schema/src/main/java/org/apache/cloudstack/backup/BackupVO.java
Lines 91 to 92 in f52e058
However, the
cloud.backup_schedule
table already contains aschedule_type
column, leading to data redundancy.cloudstack/engine/schema/src/main/java/org/apache/cloudstack/backup/BackupScheduleVO.java
Lines 45 to 46 in f52e058
Because of this, the backup creation logic requires back-and-forth conversions between
DateUtil.IntervalType
andorg.apache.cloudstack.backup.Backup.Type
. For example:cloudstack/server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java
Lines 819 to 840 in f52e058
Moreover, since the relationship is based solely on the interval type, deleting backups to comply with a schedule's retention policy may unintentionally remove backups from previously deleted schedules of the same type. For instance:
HOURLY
scheduleHOURLY
schedule is created with a retention of 3This happens because the system currently treats all backups with the same interval type as belonging to the same schedule.
Therefore, to address this, the relationship between
cloud.backup
andcloud.backup_schedule
was refactored by removing theschedule_type
from thecloud.backup
table, and adding thebackup_schedule_id
column.This change makes it possible to associate each backup with a specific schedule, eliminating ambiguity and data redundancy. Manual backups will have a
NULL
value forbackup_schedule_id
, while scheduled backups will reference their respective schedule, from which the interval type can be determined.Removal of maximum allowed retention configurations
The
backup.max.hourly
,backup.max.daily
,backup.max.weekly
, andbackup.max.monthly
settings are currently used to define the maximum retention values that end users can configure. These are validated during backup schedule creation, and an exception is thrown if the specified retention exceeds the configured maximum.However, since administrators can already define backup and allocated backup storage limits per account and domain, these settings have limited practical use. This PR proposes removing them, allowing users to omit retention entirely. In this approach, backup limits are enforced solely through account and domain-level control limits.
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Screenshots (if appropriate):
How Has This Been Tested?