Skip to content

Commit

Permalink
[PBM-1179] Warn about unsupported MongoDB version
Browse files Browse the repository at this point in the history
  • Loading branch information
defbin committed Sep 15, 2023
1 parent f4ebcb3 commit 8262201
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
7 changes: 6 additions & 1 deletion agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ func (a *Agent) CanStart() error {
return errors.New("mongos is not supported")
}

return nil
ver, err := pbm.GetMongoVersion(context.Background(), a.pbm.Conn)
if err != nil {
return errors.WithMessage(err, "get mongo version")
}

return pbm.FeatureSupport(ver).PBMSupport()
}

// Start starts listening the commands stream.
Expand Down
9 changes: 9 additions & 0 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"encoding/json"
"fmt"
stdlog "log"
"os"
"strings"
"time"
Expand Down Expand Up @@ -352,6 +353,14 @@ func Main() {
exitErr(errors.Wrap(err, "connect to mongodb"), pbmOutF)
}
pbmClient.InitLogger("", "")

ver, err := pbm.GetMongoVersion(ctx, pbmClient.Conn)
if err != nil {
stdlog.Fatalf("get mongo version: %v", err)
}
if err := pbm.FeatureSupport(ver).PBMSupport(); err != nil {
stdlog.Fatal(err.Error())
}
}

switch cmd {
Expand Down
14 changes: 14 additions & 0 deletions pbm/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ func GetMongoVersion(ctx context.Context, m *mongo.Client) (MongoVersion, error)

type FeatureSupport MongoVersion

func (f FeatureSupport) PBMSupport() error {
v := MongoVersion(f)

if v.Version[0] == 4 && v.Version[1] == 4 {
return nil
}

if (v.Version[0] == 5 || v.Version[0] == 6) && v.Version[1] == 0 {
return nil
}

return errors.New("Unsupported MongoDB version. PBM works with v4.4, v5.0, v6.0")
}

func (f FeatureSupport) FullPhysicalBackup() bool {
// PSMDB 4.2.15, 4.4.6
v := MongoVersion(f)
Expand Down

0 comments on commit 8262201

Please sign in to comment.