Skip to content

Commit

Permalink
Merge pull request #943 from percona/release-2.5.0
Browse files Browse the repository at this point in the history
Release 2.5.0
  • Loading branch information
defbin authored May 16, 2024
2 parents 883fd63 + 0d1a4ce commit 883ad72
Show file tree
Hide file tree
Showing 919 changed files with 45,958 additions and 28,544 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ on:

jobs:
test:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
timeout-minutes: 120
strategy:
fail-fast: false
Expand All @@ -36,30 +36,30 @@ jobs:
test: [logical, physical, incremental, external]
env:
PBM_BRANCH: ${{ github.event.inputs.pbm_branch || 'main' }}
GO_VER: ${{ github.event.inputs.go_ver || '1.19-bullseye' }}
GO_VER: ${{ github.event.inputs.go_ver || 'bullseye' }}
PR_NUMBER: ${{ github.event.number|| github.event.inputs.pr_ver }}

steps:
- name: Checkout testing repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: Percona-QA/psmdb-testing
ref: ${{ github.event.inputs.tests_ver || 'main'}}
path: psmdb-testing

- name: Setup environment with PSMDB ${{ matrix.psmdb }} for PBM PR/branch ${{ github.event.pull_request.title || env.PR_NUMBER || env.PBM_BRANCH }}
run: |
PSMDB=percona/percona-server-mongodb:${{ matrix.psmdb }} docker-compose build
docker-compose up -d
PSMDB=percona/percona-server-mongodb:${{ matrix.psmdb }} docker compose build
docker compose up -d
working-directory: psmdb-testing/pbm-functional/pytest

- name: Test ${{ matrix.test }} backup/restore on PSMDB ${{ matrix.psmdb }} for PBM PR/branch ${{ github.event.pull_request.title || env.PR_NUMBER || env.PBM_BRANCH }}
run: |
docker-compose run test pytest -s --junitxml=junit.xml -k ${{ matrix.test }}
docker compose run test pytest -s --junitxml=junit.xml -k ${{ matrix.test }}
working-directory: psmdb-testing/pbm-functional/pytest

- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
uses: mikepenz/action-junit-report@v4
if: success() || failure()
with:
report_paths: "**/junit.xml"
27 changes: 15 additions & 12 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ jobs:
name: runner / go-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "1.19"
go-version: "1.22"
- name: test
run: go test -v ./...

shellcheck:
name: runner / shellcheck
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.changed_files < 301 }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: spellcheck
uses: reviewdog/action-shellcheck@v1
with:
Expand All @@ -30,8 +31,9 @@ jobs:
misspell:
name: runner / misspell
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.changed_files < 301 }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: misspell
uses: reviewdog/action-misspell@v1
with:
Expand All @@ -45,8 +47,9 @@ jobs:
alex:
name: runner / alex
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.changed_files < 301 }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: alex
uses: reviewdog/action-alex@v1
with:
Expand All @@ -56,10 +59,10 @@ jobs:
name: runner / golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "1.19"
go-version: "1.22"
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
Expand All @@ -70,12 +73,12 @@ jobs:
name: runner / gofmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "1.19"
go-version: "1.22"
- run: go install golang.org/x/tools/cmd/goimports@latest
- run: go install mvdan.cc/gofumpt@v0.5.0
- run: go install mvdan.cc/gofumpt@latest
- run: goimports -w -local "github.com/percona" $(find . -not -path "*/vendor/*" -name "*.go")
- run: gofumpt -w -extra $(find . -not -path "*/vendor/*" -name "*.go")
- uses: reviewdog/action-suggester@v1
Expand All @@ -86,10 +89,10 @@ jobs:
name: runner / shfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "1.19"
go-version: "1.22"
- run: go install mvdan.cc/sh/v3/cmd/shfmt@latest
- run: shfmt -f . | grep -v 'vendor' | xargs shfmt -w -s
- name: suggester / shfmt
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@master
Expand Down
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @defbin
* @defbin @boris-ilijic
25 changes: 14 additions & 11 deletions cmd/pbm-agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,33 @@ type Agent struct {
}

func newAgent(ctx context.Context, leadConn connect.Client, uri string, dumpConns int) (*Agent, error) {
m, err := connect.MongoConnect(ctx, uri, &connect.MongoConnectOptions{Direct: true})
nodeConn, err := connect.MongoConnect(ctx, uri, connect.Direct(true))
if err != nil {
return nil, err
}

info, err := topo.GetNodeInfo(ctx, m)
info, err := topo.GetNodeInfo(ctx, nodeConn)
if err != nil {
return nil, errors.Wrap(err, "get node info")
}

mongoVersion, err := version.GetMongoVersion(ctx, m)
mongoVersion, err := version.GetMongoVersion(ctx, nodeConn)
if err != nil {
return nil, errors.Wrap(err, "get mongo version")
}

a := &Agent{
leadConn: leadConn,
closeCMD: make(chan struct{}),
nodeConn: nodeConn,
brief: topo.NodeBrief{
URI: uri,
SetName: info.SetName,
Me: info.Me,
},
mongoVersion: mongoVersion,
dumpConns: dumpConns,
}
a.nodeConn = m
a.brief = topo.NodeBrief{
URI: uri,
SetName: info.SetName,
Me: info.Me,
}
a.mongoVersion = mongoVersion
a.dumpConns = dumpConns
return a, nil
}

Expand Down Expand Up @@ -103,6 +103,9 @@ func (a *Agent) Start(ctx context.Context) error {
logger := log.FromContext(ctx)
logger.Printf("pbm-agent:\n%s", version.Current().All(""))
logger.Printf("node: %s/%s", a.brief.SetName, a.brief.Me)
logger.Printf("conn level ReadConcern: %v; WriteConcern: %v",
a.leadConn.MongoOptions().ReadConcern.Level,
a.leadConn.MongoOptions().WriteConcern.W)

c, cerr := ctrl.ListenCmd(ctx, a.leadConn, a.closeCMD)

Expand Down
1 change: 0 additions & 1 deletion cmd/pbm-agent/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ func deleteChunks(ctx context.Context, m connect.Client, stg storage.Storage, ch
{"end_ts", chnk.EndTS},
},
)

if err != nil {
return errors.Wrap(err, "delete pitr chunk metadata")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/pbm-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func runAgent(mongoURI string, dumpConns int) error {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

leadConn, err := connect.Connect(ctx, mongoURI, &connect.ConnectOptions{AppName: "pbm-agent"})
leadConn, err := connect.Connect(ctx, mongoURI, "pbm-agent")
if err != nil {
return errors.Wrap(err, "connect to PBM")
}
Expand Down
18 changes: 0 additions & 18 deletions cmd/pbm-speed-test/b_test.go

This file was deleted.

20 changes: 6 additions & 14 deletions cmd/pbm-speed-test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import (
"context"
"fmt"
stdlog "log"
"math/rand"
"os"
"time"

"github.com/alecthomas/kingpin"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"

"github.com/percona/percona-backup-mongodb/pbm/compress"
Expand Down Expand Up @@ -63,8 +61,6 @@ func main() {
*sampleSizeF = 1
}

rand.Seed(time.Now().UnixNano())

switch cmd {
case compressionCmd.FullCommand():
fmt.Print("Test started ")
Expand All @@ -90,7 +86,7 @@ func testCompression(mURL string, compression compress.CompressionType, level *i
var cn *mongo.Client

if collection != "" {
cn, err := connect.MongoConnect(ctx, mURL, &connect.MongoConnectOptions{Direct: true})
cn, err := connect.MongoConnect(ctx, mURL, connect.Direct(true))
if err != nil {
stdlog.Fatalln("Error: connect to mongodb-node:", err)
}
Expand All @@ -112,23 +108,19 @@ func testCompression(mURL string, compression compress.CompressionType, level *i
}

func testStorage(mURL string, compression compress.CompressionType, level *int, sizeGb float64, collection string) {
ctx := context.Background()

sess, err := connect.MongoConnect(ctx, mURL, &connect.MongoConnectOptions{Direct: true})
sess, err := connect.MongoConnect(context.Background(), mURL, connect.Direct(true))
if err != nil {
stdlog.Fatalln("Error: connect to mongodb-node:", err)
}
defer sess.Disconnect(ctx) //nolint:errcheck
defer sess.Disconnect(context.Background()) //nolint:errcheck

client, err := connect.Connect(ctx, mURL, &connect.ConnectOptions{AppName: "pbm-speed-test"})
client, err := connect.Connect(context.Background(), mURL, "pbm-speed-test")
if err != nil {
stdlog.Fatalln("Error: connect to mongodb-pbm:", err)
}
defer client.Disconnect(ctx) //nolint:errcheck
defer client.Disconnect(context.Background()) //nolint:errcheck

l := log.FromContext(ctx).
NewEvent("", "", "", primitive.Timestamp{})
stg, err := util.GetStorage(ctx, client, l)
stg, err := util.GetStorage(context.Background(), client, log.DiscardEvent)
if err != nil {
stdlog.Fatalln("Error: get storage:", err)
}
Expand Down
32 changes: 13 additions & 19 deletions cmd/pbm-speed-test/speedt.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@ import (
"context"
"fmt"
"io"
"reflect"
"strings"
"time"
"unsafe"

"github.com/percona/percona-backup-mongodb/pbm/compress"

"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"

"github.com/percona/percona-backup-mongodb/pbm/compress"
"github.com/percona/percona-backup-mongodb/pbm/errors"

"github.com/percona/percona-backup-mongodb/pbm/storage"
)

Expand Down Expand Up @@ -54,20 +50,25 @@ func (b Byte) String() string {
}

type Rand struct {
size Byte
size Byte
dataset [][]byte
}

func NewRand(size Byte) *Rand {
r := &Rand{
size: size,
size: size,
dataset: make([][]byte, len(dataset)),
}
for i, s := range dataset {
r.dataset[i] = []byte(s)
}
return r
}

func (r *Rand) WriteTo(w io.Writer) (int64, error) {
var written int64
for i := 0; written < int64(r.size); i++ {
n, err := w.Write(StringToBytes(dataset[i%len(dataset)]))
n, err := w.Write(r.dataset[i%len(dataset)])
if err != nil {
return written, err
}
Expand All @@ -87,10 +88,11 @@ func NewCollection(size Byte, cn *mongo.Client, namespace string) (*Collection,
return nil, errors.New("namespace should be in format `database.collection`")
}

return &Collection{
r := &Collection{
size: size,
c: cn.Database(ns[0]).Collection(ns[1]),
}, nil
}
return r, nil
}

func (c *Collection) WriteTo(w io.Writer) (int64, error) {
Expand All @@ -104,7 +106,7 @@ func (c *Collection) WriteTo(w io.Writer) (int64, error) {

var written int64
for cur.Next(ctx) {
n, err := w.Write([]byte(cur.Current))
n, err := w.Write(cur.Current)
if err != nil {
return written, errors.Wrap(err, "write")
}
Expand Down Expand Up @@ -149,11 +151,3 @@ func doTest(

return r, nil
}

// StringToBytes converts given string to the slice of bytes
// without allocations
func StringToBytes(s string) []byte {
sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
bh := reflect.SliceHeader{sh.Data, sh.Len, sh.Len}
return *(*[]byte)(unsafe.Pointer(&bh)) //nolint:govet
}
2 changes: 1 addition & 1 deletion cmd/pbm/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ func describeBackup(ctx context.Context, conn connect.Client, pbm sdk.Client, b
var stg storage.Storage
if b.coll {
l := log.FromContext(ctx).NewDefaultEvent()
stg, err := util.GetStorage(ctx, conn, l)
stg, err = util.GetStorage(ctx, conn, l)
if err != nil {
return nil, errors.Wrap(err, "get storage")
}
Expand Down
Loading

0 comments on commit 883ad72

Please sign in to comment.