Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PLAT-12864][PLAT-12865] Add support for Scheduled backups and Increm…
…ental backups in Operator Summary: Added support for scheduled backups and incremental backups in operator. **Backup Schedules:** Sample BackupSchedule CR: ``` apiVersion: operator.yugabyte.io/v1alpha1 kind: BackupSchedule metadata: name: operator-scheduled-backup-1 spec: backupType: PGSQL_TABLE_TYPE storageConfig: s3-config-operator universe: operator-universe-test-2 timeBeforeDelete: 1234567890 keyspace: test schedulingFrequency: 3600000 incrementalBackupFrequency: 900000 ``` Implementation details: Backup schedules support taking full backups using cron expressions/frequency based and also support taking incremental backups in between the full backups. When a backup currently triggered belongs to a schedule, we create corresponding CR for the corresponding backup and name it appropriately. The CRs are marked with "ignore-reconciler-add" to prevent reconciler add trying to handle them. Schedules have owner references to the universe. When the source universe is removed, the schedule also receives a delete call. Schedule actions are retry-able. I made use of the OperatorWorkQueue and custom reconciler to achieve this, much like the YBUniverse does. BackupSchedule CR also supports the "enable PointInTimeRestore" feature. **Incremental Backups** Sample CR: ``` apiVersion: operator.yugabyte.io/v1alpha1 kind: Backup metadata: name: operator-backup-1 spec: backupType: PGSQL_TABLE_TYPE storageConfig: az-config-operator-1 universe: operator-universe-test-1 timeBeforeDelete: 1234567890 keyspace: test incrementalBackupBase: <base full backup> ``` Implementation details: Incremental backups have owner references to the previous backup in the backup chain be it full/incremental backup. Thus they form a chain of references ending at the first full backup. Whenever an incremental backup is added, it is appended over the last successful backup( incremental/full ) in that chain. When an incremental is deleted, it will fail since we don't allow deleting backups in the chain unless they are failed, the same behavior is maintained here. To delete the backups, we can delete the first full backup which triggers a chain of deletes. **Misc** - There were multiple issues with backups deletion, have fixed them. - Added generic methods to handle multiple resource types. - Did some logic changes wherever necessary to accommodate the current changes. - Added handler class for Schedule. Test Plan: **Verified multiple scenarios:** - Adding scheduled backups with retry {F336728} - Schedules have owner references ``` apiVersion: operator.yugabyte.io/v1alpha1 kind: BackupSchedule metadata: annotations: universeUUID: f2d646b4-6158-4d30-b088-c116a14142bb creationTimestamp: "2025-02-27T06:42:08Z" finalizers: - finalizer.k8soperator.yugabyte.com generation: 1 name: operator-scheduled-backup-1 namespace: schedule-cr ownerReferences: - apiVersion: operator.yugabyte.io/v1alpha1 blockOwnerDeletion: true kind: YBUniverse name: operator-universe-test-2 uid: fee37102-f770-49fe-a740-c9562fa290d6 resourceVersion: "1047507613" uid: a6402732-b91a-4454-a873-89c2131064b3 ``` - Schedules are removed when Universe is removed ``` [kv83821@dev-server-kv83821 operator-crs]$ kubectl get backupschedule -n schedule-cr NAME AGE operator-scheduled-backup-1 101m [kv83821@dev-server-kv83821 operator-crs]$ kubectl get ybuniverse -n schedule-cr NAME STATE SOFTWARE VERSION operator-universe-test-2 Ready 2.25.2.0-b40 [kv83821@dev-server-kv83821 operator-crs]$ kubectl delete ybuniverse operator-universe-test-2 -n schedule-cr ybuniverse.operator.yugabyte.io "operator-universe-test-2" deleted [kv83821@dev-server-kv83821 operator-crs]$ kubectl get backupschedule -n schedule-cr No resources found in schedule-cr namespace. ``` - Creating full and incremental backups with schedule( auto created CRs ) ``` [kv83821@dev-server-kv83821 operator-crs]$ kubectl get backups -n schedule-cr NAME AGE operator-scheduled-backup-1-1069296176-full-2025-02-27-06-43-25 32m operator-scheduled-backup-1-1069296176-incremental-2025-02-27-06-59-26 16m operator-scheduled-backup-1-1069296176-incremental-2025-02-27-07-13-26 2m55s ``` - Deleting full backup deletes full and and all incremental backups ``` [kv83821@dev-server-kv83821 operator-crs]$ kubectl get backups -n schedule-cr NAME AGE operator-scheduled-backup-1-1069296176-full-2025-02-27-06-43-25 32m operator-scheduled-backup-1-1069296176-incremental-2025-02-27-06-59-26 16m operator-scheduled-backup-1-1069296176-incremental-2025-02-27-07-13-26 2m55s [kv83821@dev-server-kv83821 operator-crs]$ kubectl delete backup operator-scheduled-backup-1-1069296176-full-2025-02-27-06-43-25 -n schedule-cr backup.operator.yugabyte.io "operator-scheduled-backup-1-1069296176-full-2025-02-27-06-43-25" deleted [kv83821@dev-server-kv83821 operator-crs]$ kubectl get backups -n schedule-cr No resources found in schedule-cr namespace. ``` - Tested Edit schedule workflow works as expected. Also verified bad schedules keep retrying until the correct schedule params are applied. - Added Unit tests Reviewers: anijhawan, dshubin Reviewed By: anijhawan Differential Revision: https://phorge.dev.yugabyte.com/D42204
- Loading branch information