Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.0 -> main] Prometheus: Ensure valid unique_conn_node_id #1880

Merged
merged 4 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4765,9 +4765,18 @@ namespace eosio {
++num_peers;
}
fc::unique_lock g_conn(c->conn_mtx);
if (c->unique_conn_node_id.empty()) { // still connecting, use temp id so that non-connected peers are reported
if (!c->p2p_address.empty()) {
c->unique_conn_node_id = fc::sha256::hash(c->p2p_address).str().substr(0, 7);
} else if (!c->remote_endpoint_ip.empty()) {
c->unique_conn_node_id = fc::sha256::hash(c->remote_endpoint_ip).str().substr(0, 7);
} else {
c->unique_conn_node_id = fc::sha256::hash(std::to_string(c->connection_id)).str().substr(0, 7);
}
}
std::string conn_node_id = c->unique_conn_node_id;
boost::asio::ip::address_v6::bytes_type addr = c->remote_endpoint_ip_array;
std::string p2p_addr = c->p2p_address;
std::string conn_node_id = c->unique_conn_node_id;
g_conn.unlock();
per_connection.peers.emplace_back(
net_plugin::p2p_per_connection_metrics::connection_metric{
Expand Down
4 changes: 2 additions & 2 deletions tests/p2p_sync_throttle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def extractPrometheusMetric(connID: str, metric: str, text: str):
time.sleep(0.5)
continue
Print('Throttling Node Start State')
throttlingNodePortMap = {port: id for id, port in connPorts if id != '' and port != '9877'}
throttlingNodePortMap = {port: id for id, port in connPorts if port != '0' and port != '9877'}
throttlingNodeConnId = next(iter(throttlingNodePortMap.values())) # 9879
startSyncThrottlingBytesSent = extractPrometheusMetric(throttlingNodeConnId,
'block_sync_bytes_sent',
Expand Down Expand Up @@ -181,7 +181,7 @@ def extractPrometheusMetric(connID: str, metric: str, text: str):
errorLimit -= 1
continue
Print('Throttled Node Start State')
throttledNodePortMap = {port: id for id, port in connPorts if id != ''}
throttledNodePortMap = {port: id for id, port in connPorts if port != '0'}
throttledNodeConnId = next(iter(throttledNodePortMap.values())) # 9878
Print(throttledNodeConnId)
startSyncThrottledBytesReceived = extractPrometheusMetric(throttledNodeConnId,
Expand Down