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 eb4321b
Show file tree
Hide file tree
Showing 3 changed files with 21 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: default
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 @@ -3,6 +3,7 @@ package periodicbackupcontroller
import (
"context"
"fmt"
"slices"
"time"

backupv1alpha1 "github.com/openshift/api/config/v1alpha1"
Expand Down Expand Up @@ -80,6 +81,11 @@ func (c *PeriodicBackupController) sync(ctx context.Context, _ factory.SyncConte
return fmt.Errorf("PeriodicBackupController could not list backup CRDs, error was: %w", err)
}

// ignore reconciliation of default backup
backups.Items = slices.DeleteFunc(backups.Items, func(b backupv1alpha1.Backup) bool {
return b.Name == "default"
})

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

0 comments on commit eb4321b

Please sign in to comment.