Skip to content

Commit 42b68e4

Browse files
committed
Add more details to logs
1 parent 4208122 commit 42b68e4

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

crates/router/src/auth/client.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::sync::{Arc, Mutex};
22
use std::time::{Duration, Instant};
33

44
use serde::Deserialize;
5+
use tracing::{error, warn};
56
use url::Url;
67

78
use super::clock::{system_clock, Clock};
@@ -231,6 +232,7 @@ impl NetworkApiClient {
231232
let url = match base_url.join("internal/validate") {
232233
Ok(u) => u,
233234
Err(_) => {
235+
error!("failed to build /internal/validate URL");
234236
permit.record_failure();
235237
return ValidateResult::FailOpen;
236238
}
@@ -273,7 +275,8 @@ impl NetworkApiClient {
273275
expires_at,
274276
}
275277
}
276-
Err(_) => {
278+
Err(err) => {
279+
error!(%err, "malformed /internal/validate 200 body");
277280
VALIDATE_CALL_TOTAL.with_label_values(&["fail_open"]).inc();
278281
permit.record_failure();
279282
ValidateResult::FailOpen
@@ -302,12 +305,20 @@ impl NetworkApiClient {
302305
// Looks like a non-API 404 (misrouted, gateway error
303306
// page, etc.). Fail open so a deployment problem
304307
// doesn't masquerade as a flood of revoked keys.
308+
error!("/internal/validate returned non-JSON 404");
305309
VALIDATE_CALL_TOTAL.with_label_values(&["fail_open"]).inc();
306310
permit.record_failure();
307311
ValidateResult::FailOpen
308312
}
309313
}
310-
_ => {
314+
Ok(r) => {
315+
warn!(status = %r.status(), "/internal/validate returned unexpected HTTP status");
316+
VALIDATE_CALL_TOTAL.with_label_values(&["fail_open"]).inc();
317+
permit.record_failure();
318+
ValidateResult::FailOpen
319+
}
320+
Err(err) => {
321+
warn!(%err, "/internal/validate transport failure");
311322
VALIDATE_CALL_TOTAL.with_label_values(&["fail_open"]).inc();
312323
permit.record_failure();
313324
ValidateResult::FailOpen

crates/router/src/auth/middleware.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ async fn decide<B>(state: &AuthState, req: &mut Request<B>) -> (Outcome, Option<
265265
}
266266
ValidateResult::FailOpen => {
267267
state.cache.put_failed_recently(token.to_string());
268-
warn!("Network API unreachable; failing open");
269268
Outcome::FailOpen
270269
}
271270
};

0 commit comments

Comments
 (0)