Skip to content

Commit

Permalink
skip recurring backups upon default annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
Elbehery committed Jul 9, 2024
1 parent fbd8c0b commit a15f310
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions hack/defaultbackupcr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: config.openshift.io/v1alpha1
kind: Backup
metadata:
name: testbackup
annotations:
default: "true"
spec:
etcd:
schedule: "20 4 * * *"
timeZone: "UTC"
retentionPolicy:
retentionType: RetentionNumber
retentionNumber:
maxNumberOfBackups: 5
1 change: 1 addition & 0 deletions pkg/cmd/backuprestore/backupnoconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

type backupNoConfig struct {
snapshotExist bool
retention string
backupOptions
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ func (c *PeriodicBackupController) sync(ctx context.Context, _ factory.SyncConte
if err != nil {
return fmt.Errorf("PeriodicBackupController could not list backup CRDs, error was: %w", err)
}
// skip if default backup enabled
if v1.HasAnnotation(backups.Items[0].ObjectMeta, "default") {
klog.V(4).Info("PeriodicBackupController is skipped due to default backup being enabled")
return nil
}

for _, item := range backups.Items {
err := reconcileCronJob(ctx, cronJobsClient, item, c.operatorImagePullSpec)
Expand Down

0 comments on commit a15f310

Please sign in to comment.