Skip to content

Commit

Permalink
fix(cloud): add clean timeout for matchmaker logs (#942)
Browse files Browse the repository at this point in the history
Fixes RVTEE-134
  • Loading branch information
NathanFlurry committed Jun 25, 2024
1 parent 09890e5 commit a395e3f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion infra/tf/vector/vector.tf
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ resource "helm_release" "vector" {
ca_file = "/usr/local/share/ca-certificates/clickhouse-ca.crt"
} : {}
batch = {
timeout_secs = 5.0
# Speed up for realtime-ish logs
timeout_secs = 1.0
}
}

Expand Down
7 changes: 7 additions & 0 deletions lib/util/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ pub mod sort;
pub mod timestamp;
pub mod uuid;

pub mod watch {
/// Represented in seconds.
///
/// See docs/infrastructure/TIMEOUTS.md for reasoning.
pub const DEFAULT_TIMEOUT: u64 = 40 * 1000;
}

#[cfg(feature = "serde")]
pub mod serde {
use aws_smithy_types::Document;
Expand Down
7 changes: 1 addition & 6 deletions lib/util/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ use syn::{
Expr, Ident, Result, Token,
};

/// Represented in seconds.
///
/// See docs/infrastructure/TIMEOUTS.md for reasoning.
const DEFAULT_TIMEOUT: u64 = 40 * 1000;

mod kw {
syn::custom_keyword!(JITTER);
}
Expand Down Expand Up @@ -172,7 +167,7 @@ pub fn select_with_timeout(item: TokenStream) -> TokenStream {
let (timeout, timeout_scale) = data
.timeout
.map(|(timeout, timeout_scale)| (timeout.to_token_stream(), timeout_scale))
.unwrap_or((quote! { #DEFAULT_TIMEOUT }, 1));
.unwrap_or((quote! { util::watch::DEFAULT_TIMEOUT }, 1));
let returning = data.returning.map_or_else(
|| {
quote! {Default::default()}
Expand Down
5 changes: 5 additions & 0 deletions svc/api/cloud/src/route/games/matchmaker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ pub async fn get_lobby_logs(
break logs_res;
}

// Timeout cleanly
if query_start.elapsed().as_millis() > util::watch::DEFAULT_TIMEOUT as u128 {
break job_log::read::Response { entries: Vec::new() };
}

// Throttle request
//
// We don't use `tokio::time::interval` because if the request takes longer than 500
Expand Down

0 comments on commit a395e3f

Please sign in to comment.