Skip to content

Commit b8a1286

Browse files
authored
Merge pull request #1131 from percona/PBM-772-Use-hello-command-instead-of-isMaster
PBM-772 Use "hello" command instead of "isMaster"
2 parents 9408277 + bcfd32d commit b8a1286

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

e2e-tests/pkg/pbm/mongod.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ func (m *Mongo) GetCounters() ([]Counter, error) {
257257

258258
func (m *Mongo) GetNodeInfo() (*topo.NodeInfo, error) {
259259
inf := &topo.NodeInfo{}
260-
err := m.cn.Database("test").RunCommand(m.ctx, bson.M{"isMaster": 1}).Decode(inf)
260+
err := m.cn.Database("test").RunCommand(m.ctx, bson.M{"hello": 1}).Decode(inf)
261261
if err != nil {
262262
return nil, errors.Wrap(err, "run mongo command")
263263
}

pbm/connect/todo.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type nodeInfo struct {
1717
Me string `bson:"me"`
1818
SetName string `bson:"setName,omitempty"`
1919
Primary string `bson:"primary,omitempty"`
20-
IsPrimary bool `bson:"ismaster"`
20+
IsPrimary bool `bson:"isWritablePrimary"`
2121
ConfigSvr int `bson:"configsvr,omitempty"`
2222
ConfigServerState *struct {
2323
OpTime *struct {
@@ -59,9 +59,9 @@ type mongodOpts struct {
5959
}
6060

6161
func getNodeInfo(ctx context.Context, m *mongo.Client) (*nodeInfo, error) {
62-
res := m.Database(defs.DB).RunCommand(ctx, bson.D{{"isMaster", 1}})
62+
res := m.Database(defs.DB).RunCommand(ctx, bson.D{{"hello", 1}})
6363
if err := res.Err(); err != nil {
64-
return nil, errors.Wrap(err, "cmd: isMaster")
64+
return nil, errors.Wrap(err, "cmd: hello")
6565
}
6666

6767
n := &nodeInfo{}

pbm/topo/node.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ type NodeInfo struct {
8181
SetName string `bson:"setName,omitempty"`
8282
Primary string `bson:"primary,omitempty"`
8383
SetVersion int32 `bson:"setVersion,omitempty"`
84-
IsPrimary bool `bson:"ismaster"`
84+
IsPrimary bool `bson:"isWritablePrimary"`
8585
Secondary bool `bson:"secondary,omitempty"`
8686
Hidden bool `bson:"hidden,omitempty"`
8787
Passive bool `bson:"passive,omitempty"`
@@ -238,9 +238,9 @@ func GetNodeInfoExt(ctx context.Context, m *mongo.Client) (*NodeInfo, error) {
238238
}
239239

240240
func GetNodeInfo(ctx context.Context, m *mongo.Client) (*NodeInfo, error) {
241-
res := m.Database(defs.DB).RunCommand(ctx, bson.D{{"isMaster", 1}})
241+
res := m.Database(defs.DB).RunCommand(ctx, bson.D{{"hello", 1}})
242242
if err := res.Err(); err != nil {
243-
return nil, errors.Wrap(err, "cmd: isMaster")
243+
return nil, errors.Wrap(err, "cmd: hello")
244244
}
245245

246246
n := &NodeInfo{}

0 commit comments

Comments
 (0)