Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PBM-1179] Warn about unsupported MongoDB version #876

Merged
merged 2 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

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 {
fmt.Fprintf(os.Stderr, "WARNING: %v\n", err)
}
}

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
Loading