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

change(log): Silence verbose failed connection logs #8072

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Changes from 1 commit
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
17 changes: 15 additions & 2 deletions zebra-network/src/peer_set/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -861,10 +861,11 @@
let address_book_updater = address_book_updater.clone();
let demand_tx = demand_tx.clone();

// Increment the connection count before we spawn the connection.

Check failure on line 864 in zebra-network/src/peer_set/initialize.rs

View workflow job for this annotation

GitHub Actions / Rustfmt

Diff in /home/runner/work/zebra/zebra/zebra-network/src/peer_set/initialize.rs
let outbound_connection_tracker = active_outbound_connections.track_connection();
let outbound_connections = active_outbound_connections.update_count();
debug!(
outbound_connections = ?active_outbound_connections.update_count(),
?outbound_connections,
"opening an outbound peer connection"
);

Expand Down Expand Up @@ -892,6 +893,7 @@
candidate,
outbound_connector,
outbound_connection_tracker,
outbound_connections,
peerset_tx,
address_book_updater,
demand_tx,
Expand Down Expand Up @@ -1026,6 +1028,7 @@
#[instrument(skip(
outbound_connector,
outbound_connection_tracker,
outbound_connections,
peerset_tx,
address_book_updater,
demand_tx
Expand All @@ -1034,6 +1037,7 @@
candidate: MetaAddr,
mut outbound_connector: C,
outbound_connection_tracker: ConnectionTracker,
outbound_connections: usize,
mut peerset_tx: futures::channel::mpsc::Sender<DiscoveredPeer>,
address_book_updater: tokio::sync::mpsc::Sender<MetaAddrChange>,
mut demand_tx: futures::channel::mpsc::Sender<MorePeers>,
Expand All @@ -1048,6 +1052,9 @@
+ 'static,
C::Future: Send + 'static,
{
// The maximum number of open or pending connections before we log an info-level message.
teor2345 marked this conversation as resolved.
Show resolved Hide resolved
const MAX_CONNECTIONS_FOR_INFO_LOG: usize = 5;

// # Correctness
//
// To avoid hangs, the dialer must only await:
Expand Down Expand Up @@ -1076,7 +1083,13 @@
}
// The connection was never opened, or it failed the handshake and was dropped.
Err(error) => {
info!(?error, ?candidate.addr, "failed to make outbound connection to peer");
// Silence verbose info logs in production, but keep logs if the number of connections is low.
// Also silence them completely in tests.
if outbound_connections <= MAX_CONNECTIONS_FOR_INFO_LOG && !cfg!(test) {
info!(?error, ?candidate.addr, "failed to make outbound connection to peer");
} else {
debug!(?error, ?candidate.addr, "failed to make outbound connection to peer");
}
report_failed(address_book_updater.clone(), candidate).await;

// The demand signal that was taken out of the queue to attempt to connect to the
Expand Down
Loading