Skip to content

Commit 27754a5

Browse files
committed
Fix reporting hosts for cfg srv in PSMDB 6
1 parent 0aea022 commit 27754a5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pbm/topo/cluster.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,15 @@ func getShardMapImpl(ctx context.Context, m *mongo.Client) (map[ReplsetName]Shar
182182
hostsByShard[shardID] = append(hostsByShard[shardID], host)
183183
}
184184

185+
// for PSMDB 6 and below, config srv is not reported within hosts field
186+
if len(hostsByShard["config"]) == 0 {
187+
cfgHostgs, err := GetReplsetHosts(ctx, m)
188+
if err != nil {
189+
return nil, errors.Wrap(err, "get all hosts for config RS")
190+
}
191+
hostsByShard["config"] = cfgHostgs
192+
}
193+
185194
shards := make(map[string]Shard, len(shardMap.Map))
186195
for id, host := range shardMap.Map {
187196
rs, _, _ := strings.Cut(host, "/")

0 commit comments

Comments
 (0)