Skip to content

Commit

Permalink
remove some workarounds for PBM
Browse files Browse the repository at this point in the history
  • Loading branch information
egegunes committed Nov 7, 2024
1 parent 5da01b3 commit 1dbe364
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 33 deletions.
14 changes: 0 additions & 14 deletions pkg/controller/perconaservermongodbrestore/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,6 @@ func (r *ReconcilePerconaServerMongoDBRestore) validate(ctx context.Context, cr
return errors.Wrap(err, "get backup")
}

// TODO: remove this if statement after https://perconadev.atlassian.net/browse/PBM-1360 is fixed
if bcp.Status.Type != defs.PhysicalBackup {
cjobs, err := backup.HasActiveJobs(ctx, r.newPBMFunc, r.client, cluster, backup.NewRestoreJob(cr), backup.NotPITRLock)
if err != nil {
return errors.Wrap(err, "check for concurrent jobs")
}
if cjobs {
if cr.Status.State != psmdbv1.RestoreStateWaiting {
log.Info("waiting to finish another backup/restore.")
}
return errWaitingRestore
}
}

if bcp.Status.Type != defs.LogicalBackup && cr.Spec.Selective != nil {
return errors.New("`.spec.selective` field is supported only for logical backups")
}
Expand Down
24 changes: 5 additions & 19 deletions pkg/psmdb/backup/pbm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"net/url"
"os"
"path"
"strings"
"time"

Expand All @@ -23,7 +22,6 @@ import (
"github.com/percona/percona-backup-mongodb/pbm/config"
"github.com/percona/percona-backup-mongodb/pbm/connect"
"github.com/percona/percona-backup-mongodb/pbm/ctrl"
"github.com/percona/percona-backup-mongodb/pbm/defs"
"github.com/percona/percona-backup-mongodb/pbm/lock"
pbmLog "github.com/percona/percona-backup-mongodb/pbm/log"
"github.com/percona/percona-backup-mongodb/pbm/oplog"
Expand Down Expand Up @@ -399,31 +397,19 @@ func (b *pbmC) ValidateBackup(ctx context.Context, bcp *psmdbv1.PerconaServerMon
}

e := b.Logger().NewEvent(string(ctrl.CmdRestore), "", "", primitive.Timestamp{})
backupName := bcp.Status.PBMname
stg, err := util.StorageFromConfig(&cfg.Storage, e)
if err != nil {
return errors.Wrap(err, "storage from config")
}

backupName := bcp.Status.PBMname
m, err := restore.GetMetaFromStore(stg, backupName)
if err != nil {
return errors.Wrap(err, "get backup metadata from storage")
}
switch bcp.Status.Type {
case "", defs.LogicalBackup:
if err := backup.CheckBackupFiles(ctx, stg, m.Name); err != nil {
return errors.Wrap(err, "check backup files")
}
case defs.PhysicalBackup:
for _, rs := range m.Replsets {
f := path.Join(m.Name, rs.Name)
files, err := stg.List(f, "")
if err != nil {
return errors.Wrapf(err, "failed to list backup files at %s", f)
}
if len(files) == 0 {
return errors.Wrap(err, "no physical backup files")
}
}

if err := backup.CheckBackupFiles(ctx, stg, m.Name); err != nil {
return errors.Wrap(err, "check backup files")
}

return nil
Expand Down

0 comments on commit 1dbe364

Please sign in to comment.