Skip to content

Commit e6bf0ca

Browse files
committed
Revert "Merge pull request #1102 from percona/PBM-1512-fix-node-validation-mixed-deploy"
This reverts commit 991962a, reversing changes made to 4aca65b.
1 parent 06ece30 commit e6bf0ca

File tree

2 files changed

+4
-52
lines changed

2 files changed

+4
-52
lines changed

pbm/topo/cluster.go

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package topo
22

33
import (
44
"context"
5-
"fmt"
65
"strings"
76

87
"go.mongodb.org/mongo-driver/bson"
@@ -121,7 +120,6 @@ func ClusterMembers(ctx context.Context, m *mongo.Client) ([]Shard, error) {
121120
return nil, errors.Wrap(err, "define cluster state")
122121
}
123122

124-
// sharded cluster topo
125123
var shards []Shard
126124
if inf.IsMongos() || inf.IsSharded() {
127125
members, err := getShardMapImpl(ctx, m)
@@ -137,15 +135,10 @@ func ClusterMembers(ctx context.Context, m *mongo.Client) ([]Shard, error) {
137135
return shards, nil
138136
}
139137

140-
// RS topo
141-
hosts, err := GetReplsetHosts(ctx, m)
142-
if err != nil {
143-
return nil, errors.Wrap(err, "get all hosts for RS")
144-
}
145138
shards = []Shard{{
146139
ID: inf.SetName,
147140
RS: inf.SetName,
148-
Host: fmt.Sprintf("%s/%s", inf.SetName, strings.Join(hosts, ",")),
141+
Host: inf.SetName + "/" + strings.Join(inf.Hosts, ","),
149142
}}
150143
return shards, nil
151144
}
@@ -160,44 +153,18 @@ func getShardMapImpl(ctx context.Context, m *mongo.Client) (map[ReplsetName]Shar
160153
// if shard name is not set, mongodb will provide unique name for it
161154
// (e.g. the replset name of the shard)
162155
// for configsvr, key name is "config"
163-
// hosts field is used to discover hidden members, which are not present in map field
164-
var shardMap struct {
165-
Map map[string]string
166-
Hosts map[string]string
167-
}
156+
var shardMap struct{ Map map[string]string }
168157
if err := res.Decode(&shardMap); err != nil {
169158
return nil, errors.Wrap(err, "decode")
170159
}
171160

172-
// Example of the hosts field from command output:
173-
// hosts: {
174-
// 'rs103:27017': 'rs1',
175-
// 'rs101:27017': 'rs1',
176-
// 'cfg02:27017': 'config',
177-
// ...
178-
// }
179-
// hostsByShard will contain even hidden RS members
180-
hostsByShard := map[string][]string{}
181-
for host, shardID := range shardMap.Hosts {
182-
hostsByShard[shardID] = append(hostsByShard[shardID], host)
183-
}
184-
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-
194161
shards := make(map[string]Shard, len(shardMap.Map))
195162
for id, host := range shardMap.Map {
196163
rs, _, _ := strings.Cut(host, "/")
197164
shards[rs] = Shard{
198165
ID: id,
199166
RS: rs,
200-
Host: fmt.Sprintf("%s/%s", rs, strings.Join(hostsByShard[id], ",")),
167+
Host: host,
201168
}
202169
}
203170

pbm/topo/topo.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func collectTopoCheckErrors(
109109
members := make(map[NodeURI][]error, len(hosts))
110110
for _, host := range hosts {
111111
a, ok := agents[host]
112-
if !ok || a.Arbiter {
112+
if !ok || a.Arbiter || a.Passive {
113113
continue
114114
}
115115

@@ -187,21 +187,6 @@ func GetReplsetStatus(ctx context.Context, m *mongo.Client) (*ReplsetStatus, err
187187
return status, nil
188188
}
189189

190-
// GetReplsetHosts returns host names for all RS members.
191-
// It includes also hidden and passive RS members.
192-
func GetReplsetHosts(ctx context.Context, m *mongo.Client) ([]string, error) {
193-
s, err := GetReplsetStatus(ctx, m)
194-
if err != nil {
195-
return nil, errors.Wrap(err, "get replset status")
196-
}
197-
198-
hosts := []string{}
199-
for _, m := range s.Members {
200-
hosts = append(hosts, m.Name)
201-
}
202-
return hosts, nil
203-
}
204-
205190
func GetNodeStatus(ctx context.Context, m *mongo.Client, name string) (*NodeStatus, error) {
206191
s, err := GetReplsetStatus(ctx, m)
207192
if err != nil {

0 commit comments

Comments
 (0)