@@ -3,12 +3,10 @@ package perconaservermongodb
3
3
import (
4
4
"container/heap"
5
5
"context"
6
- "fmt"
7
6
"time"
8
7
9
8
"github.com/pkg/errors"
10
9
"github.com/robfig/cron/v3"
11
- batchv1 "k8s.io/api/batch/v1"
12
10
corev1 "k8s.io/api/core/v1"
13
11
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
14
12
k8serrors "k8s.io/apimachinery/pkg/api/errors"
@@ -103,51 +101,13 @@ func (r *ReconcilePerconaServerMongoDB) createOrUpdateBackupTask(ctx context.Con
103
101
func (r * ReconcilePerconaServerMongoDB ) deleteOldBackupTasks (ctx context.Context , cr * api.PerconaServerMongoDB , ctasks map [string ]api.BackupTaskSpec ) error {
104
102
log := logf .FromContext (ctx )
105
103
106
- if cr .CompareVersion ("1.13.0" ) < 0 {
107
- ls := naming .NewBackupCronJobLabels (cr , cr .Spec .Backup .Labels )
108
- tasksList := & batchv1.CronJobList {}
109
- err := r .client .List (ctx ,
110
- tasksList ,
111
- & client.ListOptions {
112
- Namespace : cr .Namespace ,
113
- LabelSelector : labels .SelectorFromSet (ls ),
114
- },
115
- )
116
- if err != nil {
117
- return fmt .Errorf ("get backup list: %v" , err )
118
- }
119
-
120
- for _ , t := range tasksList .Items {
121
- if spec , ok := ctasks [t .Name ]; ok {
122
- // TODO: make .keep to work with incremental backups
123
- if spec .Type == defs .IncrementalBackup {
124
- continue
125
- }
126
- if spec .Keep > 0 {
127
- oldjobs , err := r .oldScheduledBackups (ctx , cr , t .Name , spec .Keep )
128
- if err != nil {
129
- return fmt .Errorf ("remove old backups: %v" , err )
130
- }
131
-
132
- for _ , todel := range oldjobs {
133
- err = r .client .Delete (ctx , & todel )
134
- if err != nil {
135
- return fmt .Errorf ("failed to delete backup object: %v" , err )
136
- }
137
- }
138
- }
139
- } else {
140
- err := r .client .Delete (ctx , & t )
141
- if err != nil && ! k8sErrors .IsNotFound (err ) {
142
- return fmt .Errorf ("delete backup task %s: %v" , t .Name , err )
143
- }
144
- }
145
- }
146
- return nil
147
- }
148
104
r .crons .backupJobs .Range (func (k , v interface {}) bool {
149
105
item := v .(BackupScheduleJob )
150
106
if spec , ok := ctasks [item .Name ]; ok {
107
+ // TODO: make .keep to work with incremental backups
108
+ if spec .Type == defs .IncrementalBackup {
109
+ return true
110
+ }
151
111
if spec .Keep > 0 {
152
112
oldjobs , err := r .oldScheduledBackups (ctx , cr , item .Name , spec .Keep )
153
113
if err != nil {
0 commit comments