-
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
Refactoring retention of backup schedules #11223
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #11223 +/- ##
============================================
+ Coverage 16.74% 17.17% +0.42%
- Complexity 14065 15010 +945
============================================
Files 5724 5869 +145
Lines 507787 521689 +13902
Branches 61733 63504 +1771
============================================
+ Hits 85046 89611 +4565
- Misses 413258 422019 +8761
- Partials 9483 10059 +576
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. |
@blueorangutan package |
@winterhazel 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 14332 |
@bernardodemarco @winterhazel is this ready (for review/testing etc)? |
@DaanHoogland yes, this PR is ready for both review and testing. |
@blueorangutan test keepEnv |
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
[SF] Trillian test result (tid-13892)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CLGTM, but I left a minor nitpick
server/src/main/java/org/apache/cloudstack/backup/BackupManagerImpl.java
Outdated
Show resolved
Hide resolved
@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 14443 |
@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 14446 |
@blueorangutan package |
@sureshanaparti 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 14461 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clgtm, and limited testing done;
- DB seems good after white box test.
- schedule id parameter is removed and that seem ok by me.
- configurations are gone as well. I wonder if these will lead to complaints by users? As they pay for backup storage space in some cases they may want to reduce the number of backup retained from the system configured one. (I don’t sell backups so I don’t have a strong opinion, just throwing it out there)
EDIT: silly to think users would use those configurations, never mind point 3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clgtm
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?