diff --git a/agent/agent.go b/agent/agent.go index a68017780..0582e91e1 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -68,6 +68,14 @@ func (a *Agent) CanStart() error { return errors.New("mongos is not supported") } + ver, err := pbm.GetMongoVersion(context.Background(), a.pbm.Conn) + if err != nil { + return errors.WithMessage(err, "get mongo version") + } + if err := pbm.FeatureSupport(ver).PBMSupport(); err != nil { + a.log.Warning("", "", "", primitive.Timestamp{}, "WARNING: %v", err) + } + return nil } diff --git a/cli/cli.go b/cli/cli.go index b104b414e..b36480c1d 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -5,6 +5,7 @@ import ( "context" "encoding/json" "fmt" + stdlog "log" "os" "strings" "time" @@ -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 { + fmt.Fprintf(os.Stderr, "WARNING: %v\n", err) + } } switch cmd { diff --git a/pbm/version.go b/pbm/version.go index fac1d5fa8..e80d5a8e0 100644 --- a/pbm/version.go +++ b/pbm/version.go @@ -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)