diff --git a/go.mod b/go.mod index cb4b592c93452..018fabc0fc57e 100644 --- a/go.mod +++ b/go.mod @@ -153,7 +153,7 @@ require ( github.com/vulcand/predicate v1.2.0 // replaced go.etcd.io/etcd/api/v3 v3.5.11 go.etcd.io/etcd/client/v3 v3.5.11 - go.mongodb.org/mongo-driver v1.13.0 + go.mongodb.org/mongo-driver v1.13.1 go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws v0.46.1 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 diff --git a/go.sum b/go.sum index 69e8c8cf35585..b367148bcc792 100644 --- a/go.sum +++ b/go.sum @@ -1559,8 +1559,8 @@ go.mongodb.org/mongo-driver v1.7.3/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R7 go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng= go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8= go.mongodb.org/mongo-driver v1.11.4/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g= -go.mongodb.org/mongo-driver v1.13.0 h1:67DgFFjYOCMWdtTEmKFpV3ffWlFnh+CYZ8ZS/tXWUfY= -go.mongodb.org/mongo-driver v1.13.0/go.mod h1:/rGBTebI3XYboVmgz+Wv3Bcbl3aD0QF9zl6kDDw18rQ= +go.mongodb.org/mongo-driver v1.13.1 h1:YIc7HTYsKndGK4RFzJ3covLz1byri52x0IoMB0Pt/vk= +go.mongodb.org/mongo-driver v1.13.1/go.mod h1:wcDf1JBCXy2mOW0bWHwO/IOYqdca1MPCwDtFu/Z9+eo= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= diff --git a/lib/srv/db/access_test.go b/lib/srv/db/access_test.go index 56d9957aa4cd3..d43d8afb7d49b 100644 --- a/lib/srv/db/access_test.go +++ b/lib/srv/db/access_test.go @@ -1003,12 +1003,12 @@ func TestMongoDBMaxMessageSize(t *testing.T) { expectedQueryError bool }{ "default message size": { - messageSize: 300, + messageSize: 400, }, "message size exceeded": { // Set a value that will enable handshake message to complete // successfully. - maxMessageSize: 300, + maxMessageSize: 400, messageSize: 500, expectedQueryError: true, }, diff --git a/lib/srv/db/mongodb/test.go b/lib/srv/db/mongodb/test.go index df266bd61b13b..a858ac05789af 100644 --- a/lib/srv/db/mongodb/test.go +++ b/lib/srv/db/mongodb/test.go @@ -217,6 +217,8 @@ func (s *TestServer) handleMessage(message protocol.Message) (protocol.Message, switch command { case commandIsMaster: return s.handleIsMaster(message) + case commandHello: + return s.handleHello(message) case commandAuth: return s.handleAuth(message) case commandPing: @@ -274,7 +276,7 @@ func (s *TestServer) handleAuth(message protocol.Message) (protocol.Message, err // handleIsMaster makes response to the client's "isMaster" command. // // isMaster command is used as a handshake by the client to determine the -// cluster topology. +// cluster topology. Replaced by hello command in newer versions. func (s *TestServer) handleIsMaster(message protocol.Message) (protocol.Message, error) { isMasterReply, err := makeIsMasterReply(s.getWireVersion(), s.getMaxMessageSize()) if err != nil { @@ -289,6 +291,28 @@ func (s *TestServer) handleIsMaster(message protocol.Message) (protocol.Message, return nil, trace.NotImplemented("unsupported message: %v", message) } +// handleHello makes response to the client's "hello" command. +// +// hello command is used as a handshake by the client to determine the +// cluster topology. +func (s *TestServer) handleHello(message protocol.Message) (protocol.Message, error) { + reply, err := bson.Marshal(bson.M{ + "ok": 1, + "isWritablePrimary": true, + "maxMessageSizeBytes": s.getMaxMessageSize(), + "maxWireVersion": s.getWireVersion(), + "readOnly": false, + "compression": []string{"zlib"}, + // `serviceId` is required for LoadBalanced mode. Reference: + // https://github.com/mongodb/specifications/blob/master/source/load-balancers/load-balancers.rst + "serviceId": primitive.NewObjectID(), + }) + if err != nil { + return nil, trace.Wrap(err) + } + return protocol.MakeOpMsg(reply), nil +} + // handlePing makes response to the client's "ping" command. // // ping command is usually used by client to test connectivity to the server. @@ -718,6 +742,7 @@ const ( commandAuth = "authenticate" commandIsMaster = "isMaster" + commandHello = "hello" commandPing = "ping" commandFind = "find" commandSaslStart = "saslStart" @@ -747,7 +772,9 @@ func makeIsMasterReply(wireVersion int, maxMessageSize uint32) ([]byte, error) { "maxWireVersion": wireVersion, "maxMessageBytes": maxMessageSize, "compression": []string{"zlib"}, - "serviceId": primitive.NewObjectID(), + // `serviceId` is required for LoadBalanced mode. Reference: + // https://github.com/mongodb/specifications/blob/master/source/load-balancers/load-balancers.rst + "serviceId": primitive.NewObjectID(), }) }