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

[Traffic Control] Fix blocked metric #20590

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
18 changes: 10 additions & 8 deletions crates/sui-core/src/traffic_controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,20 @@ impl TrafficController {
pub async fn check(&self, client: &Option<IpAddr>, proxied_client: &Option<IpAddr>) -> bool {
let check_with_dry_run_maybe = |allowed| -> bool {
match (allowed, self.dry_run_mode()) {
// check succeeded
// request allowed
(true, _) => true,
// check failed while in dry-run mode
// request blocked while in dry-run mode
(false, true) => {
debug!("Dry run mode: Blocked request from client {:?}", client);
self.metrics.num_dry_run_blocked_requests.inc();
true
}
// check failed
(false, false) => false,
// request blocked
(false, false) => {
debug!("Blocked request from client {:?}", client);
self.metrics.requests_blocked_at_protocol.inc();
true
}
}
};

Expand Down Expand Up @@ -520,8 +524,7 @@ async fn handle_policy_response(
.is_none()
{
// Only increment the metric if the client was not already blocked
debug!("Blocking client: {:?}", client);
metrics.requests_blocked_at_protocol.inc();
debug!("Adding client {:?} to blocklist", client);
metrics.connection_ip_blocklist_len.inc();
}
}
Expand All @@ -535,8 +538,7 @@ async fn handle_policy_response(
.is_none()
{
// Only increment the metric if the client was not already blocked
debug!("Blocking proxied client: {:?}", client);
metrics.requests_blocked_at_protocol.inc();
debug!("Adding proxied client {:?} to blocklist", client);
metrics.proxy_ip_blocklist_len.inc();
}
}
Expand Down
Loading