[Enhancement](heartbeat) make heartbeat ok when config repeated host-ip pairs (#21228)

This commit is contained in:
Xiangyu Wang
2023-06-28 23:12:06 +08:00
committed by GitHub
parent 449c8d4568
commit 86af533e83

View File

@ -96,7 +96,15 @@ Status hostname_to_ip_addrs(const std::string& name, std::vector<std::string>* a
return Status::InternalError("Could not convert IPv4 address for: {}", name);
}
addresses->push_back(std::string(addr_buf));
// add address if not exists
std::string address = std::string(addr_buf);
if (std::find(addresses->begin(), addresses->end(), address) != addresses->end()) {
LOG(WARNING) << "Repeated ip addresses has been found for host: " << name
<< ", ip address:" << address
<< ", please check your network configuration";
} else {
addresses->push_back(address);
}
it = it->ai_next;
}