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
2026-09-18 11:34:05 -07:00
parent 0ae7874ed9
commit 0d6024e2e0
3 changed files with 10 additions and 4 deletions
+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,
+3
View File
@@ -1351,6 +1351,9 @@ func (s *AdminServer) GetClusterMasters() (*ClusterMastersData, error) {
for _, server := range resp.ClusterServers {
// Raft stores gRPC addresses, convert to HTTP address
httpAddress := pb.GrpcAddressToServerAddress(server.Address)
if httpAddress == "" {
continue
}
// Update existing master info or create new one
if masterInfo, exists := masterMap[httpAddress]; exists {
+1 -1
View File
@@ -564,7 +564,7 @@ func GrpcAddressToServerAddress(grpcAddress string) (serverAddress string) {
host, grpcPort, parseErr := hostAndPort(grpcAddress)
if parseErr != nil {
glog.Errorf("server grpc address %s parse error: %v", grpcAddress, parseErr)
return grpcAddress
return ""
}
port := int(grpcPort) - 10000