pb: return empty server address for malformed grpc addresses

GrpcAddressToServerAddress used to return the unparseable input on a
hostAndPort failure, so a malformed raft address (e.g. "host:abc")
flowed into admin dashboard master maps unchanged. Return an empty
string instead, skip empty conversions at the two raft-cluster merge
sites, and drop the now-stale comment about the fatal exit the earlier
commit removed.
This commit is contained in:
Chris Lu committed 2026-09-18 11:34:05 -07:00
1 parent 0ae7874ed9
commit 0d6024e2e0
3 files changed
+10 -4

No files matched your search

+6 -3
View File
@@ -293,14 +293,17 @@ func (s *AdminServer) getMasterNodesStatus() []MasterNode {
}
raftCallSucceeded = true
for _, server := range resp.ClusterServers {
// pb.GrpcAddressToServerAddress calls glog.Fatalf on a parse
// error, so pre-validate the raft address with net.SplitHostPort
// and skip malformed entries instead of taking the process down.
// Skip malformed raft addresses instead of letting an
// unconvertible value into masterMap.
if _, _, splitErr := net.SplitHostPort(server.Address); splitErr != nil {
glog.Warningf("skip master with invalid raft address %q: %v", server.Address, splitErr)
continue
}
httpAddress := pb.GrpcAddressToServerAddress(server.Address)
if httpAddress == "" {
glog.Warningf("skip master with invalid raft address %q", server.Address)
continue
}
masterMap[httpAddress] = MasterNode{
Address: httpAddress,
IsLeader: server.IsLeader,