Skip to content

Commit 85d4787

Browse files
authored
Merge branch 'dev' into PBM-1482-fix-config-srv-files-download
2 parents 672b354 + e2c5d52 commit 85d4787

File tree

9 files changed

+675
-440
lines changed

9 files changed

+675
-440
lines changed

pbm/restore/logical.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,7 @@ func (r *Restore) swapUsers(ctx context.Context, exclude *topo.AuthInfo, nss []s
14081408
for _, ns := range nss {
14091409
// ns can be "*.*" or "admin.pbmRUsers" or "admin.pbmRRoles"
14101410
db, _ := util.ParseNS(ns)
1411-
if len(db) == 0 || strings.HasPrefix(db, defs.DB) {
1411+
if len(db) == 0 || db == defs.DB {
14121412
continue
14131413
}
14141414
dbs = append(dbs, db)

pbm/restore/phys/phys.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import (
88
"go.mongodb.org/mongo-driver/bson/primitive"
99

1010
"github.com/percona/percona-backup-mongodb/pbm/errors"
11-
"github.com/percona/percona-backup-mongodb/pbm/storage/s3"
11+
"github.com/percona/percona-backup-mongodb/pbm/storage"
1212
)
1313

1414
type RestoreStat struct {
1515
RS map[string]map[string]RestoreRSMetrics `bson:"rs,omitempty" json:"rs,omitempty"`
1616
}
1717
type RestoreRSMetrics struct {
18-
DistTxn DistTxnStat `bson:"txn,omitempty" json:"txn,omitempty"`
19-
Download s3.DownloadStat `bson:"download,omitempty" json:"download,omitempty"`
18+
DistTxn DistTxnStat `bson:"txn,omitempty" json:"txn,omitempty"`
19+
Download storage.DownloadStat `bson:"download,omitempty" json:"download,omitempty"`
2020
}
2121

2222
type DistTxnStat struct {
@@ -35,8 +35,8 @@ type DistTxnStat struct {
3535
}
3636

3737
type RestoreShardStat struct {
38-
Txn DistTxnStat `json:"txn"`
39-
D *s3.DownloadStat `json:"d"`
38+
Txn DistTxnStat `json:"txn"`
39+
D *storage.DownloadStat `json:"d"`
4040
}
4141

4242
type TxnState string

pbm/restore/physical.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
"github.com/percona/percona-backup-mongodb/pbm/log"
4040
"github.com/percona/percona-backup-mongodb/pbm/restore/phys"
4141
"github.com/percona/percona-backup-mongodb/pbm/storage"
42+
"github.com/percona/percona-backup-mongodb/pbm/storage/gcs"
4243
"github.com/percona/percona-backup-mongodb/pbm/storage/s3"
4344
"github.com/percona/percona-backup-mongodb/pbm/topo"
4445
"github.com/percona/percona-backup-mongodb/pbm/util"
@@ -1271,17 +1272,25 @@ func (r *PhysRestore) dumpMeta(meta *RestoreMeta, s defs.Status, msg string) err
12711272
return nil
12721273
}
12731274

1274-
func (r *PhysRestore) copyFiles() (*s3.DownloadStat, error) {
1275-
var stat *s3.DownloadStat
1275+
func (r *PhysRestore) copyFiles() (*storage.DownloadStat, error) {
1276+
var stat *storage.DownloadStat
12761277
readFn := r.bcpStg.SourceReader
1277-
if t, ok := r.bcpStg.(*s3.S3); ok {
1278+
1279+
switch t := r.bcpStg.(type) {
1280+
case *s3.S3:
1281+
d := t.NewDownload(r.confOpts.NumDownloadWorkers, r.confOpts.MaxDownloadBufferMb, r.confOpts.DownloadChunkMb)
1282+
readFn = d.SourceReader
1283+
defer func() {
1284+
s := d.Stat()
1285+
stat = &s
1286+
r.log.Debug("download stat: %s", s)
1287+
}()
1288+
case *gcs.GCS:
12781289
d := t.NewDownload(r.confOpts.NumDownloadWorkers, r.confOpts.MaxDownloadBufferMb, r.confOpts.DownloadChunkMb)
12791290
readFn = d.SourceReader
1280-
12811291
defer func() {
12821292
s := d.Stat()
12831293
stat = &s
1284-
12851294
r.log.Debug("download stat: %s", s)
12861295
}()
12871296
}

pbm/snapshot/restore.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ func NewRestore(uri string,
114114
"config.collections",
115115
"config.chunks",
116116
}
117-
nsExclude := make([]string, len(ExcludeFromRestore)+len(configColls))
117+
nsExclude = make([]string, len(ExcludeFromRestore)+len(configColls))
118118
n := copy(nsExclude, ExcludeFromRestore)
119-
copy(nsExclude[:n], configColls)
119+
copy(nsExclude[n:], configColls)
120120
}
121121

122122
mopts := mongorestore.Options{}

0 commit comments

Comments
 (0)