diff --git a/Cargo.lock b/Cargo.lock index f6f3aeacf..4b24d0ccd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -664,17 +664,6 @@ dependencies = [ "syn 2.0.37", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -981,23 +970,6 @@ dependencies = [ "phf_codegen", ] -[[package]] -name = "clap" -version = "3.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" -dependencies = [ - "atty", - "bitflags 1.3.2", - "clap_derive 3.2.18", - "clap_lex 0.2.4", - "indexmap 1.9.2", - "once_cell", - "strsim", - "termcolor", - "textwrap", -] - [[package]] name = "clap" version = "4.1.4" @@ -1005,26 +977,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76" dependencies = [ "bitflags 1.3.2", - "clap_derive 4.1.0", - "clap_lex 0.3.1", + "clap_derive", + "clap_lex", "is-terminal", "once_cell", "termcolor", ] -[[package]] -name = "clap_derive" -version = "3.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" -dependencies = [ - "heck", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.107", -] - [[package]] name = "clap_derive" version = "4.1.0" @@ -1038,15 +997,6 @@ dependencies = [ "syn 1.0.107", ] -[[package]] -name = "clap_lex" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" -dependencies = [ - "os_str_bytes", -] - [[package]] name = "clap_lex" version = "0.3.1" @@ -1147,31 +1097,12 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5ed970f886b2692d34c1976254bfae22336b12733ecb37ef0fad32128ff4bfb" -[[package]] -name = "core-foundation" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "core-foundation-sys" version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" -[[package]] -name = "cpp_demangle" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" -dependencies = [ - "cfg-if", -] - [[package]] name = "cpufeatures" version = "0.2.5" @@ -1559,15 +1490,6 @@ dependencies = [ "sqlparser", ] -[[package]] -name = "debugid" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d" -dependencies = [ - "uuid", -] - [[package]] name = "derive_more" version = "0.99.17" @@ -1651,18 +1573,6 @@ dependencies = [ "instant", ] -[[package]] -name = "findshlibs" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40b9e59cd0f7e0806cca4be089683ecb6434e602038df21fe6bf6711b2f07f64" -dependencies = [ - "cc", - "lazy_static", - "libc", - "winapi", -] - [[package]] name = "fixedbitset" version = "0.4.2" @@ -1695,21 +1605,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "form_urlencoded" version = "1.2.0" @@ -1919,15 +1814,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.2.6" @@ -2075,19 +1961,6 @@ dependencies = [ "tokio-io-timeout", ] -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes", - "hyper", - "native-tls", - "tokio", - "tokio-native-tls", -] - [[package]] name = "iana-time-zone" version = "0.1.53" @@ -2452,15 +2325,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" -[[package]] -name = "memmap2" -version = "0.5.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" -dependencies = [ - "libc", -] - [[package]] name = "memoffset" version = "0.8.0" @@ -2513,45 +2377,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "names" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7d66043b25d4a6cccb23619d10c19c25304b355a7dccd4a8e11423dd2382146" -dependencies = [ - "clap 3.2.23", - "rand", -] - -[[package]] -name = "native-tls" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - -[[package]] -name = "nix" -version = "0.24.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" -dependencies = [ - "bitflags 1.3.2", - "cfg-if", - "libc", -] - [[package]] name = "nom" version = "7.1.3" @@ -2730,50 +2555,6 @@ dependencies = [ "validator", ] -[[package]] -name = "openssl" -version = "0.10.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345df152bc43501c5eb9e4654ff05f794effb78d4efe3d53abc158baddc0703d" -dependencies = [ - "bitflags 1.3.2", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.107", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.90" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374533b0e45f3a7ced10fcaeccca020e66656bc03dac384f852e4e5a7a8104a6" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "ordered-float" version = "2.10.0" @@ -2885,7 +2666,7 @@ dependencies = [ "cargo_toml", "chrono", "chrono-humanize", - "clap 4.1.4", + "clap", "clokwerk", "cookie 0.17.0", "cookies", @@ -2913,8 +2694,6 @@ dependencies = [ "openid", "parquet", "prometheus", - "pyroscope", - "pyroscope_pprofrs", "rand", "regex", "relative-path", @@ -3069,26 +2848,6 @@ version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" -[[package]] -name = "pprof" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6472bfed9475542ac46c518734a8d06d71b0f6cb2c17f904aa301711a57786f" -dependencies = [ - "backtrace", - "cfg-if", - "findshlibs", - "libc", - "log", - "nix", - "once_cell", - "parking_lot", - "smallvec", - "symbolic-demangle", - "tempfile", - "thiserror", -] - [[package]] name = "ppv-lite86" version = "0.2.17" @@ -3193,30 +2952,6 @@ version = "2.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "106dd99e98437432fed6519dedecfade6a06a73bb7b2a1e019fdd2bee5778d94" -[[package]] -name = "pyroscope" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f94e4ab21b0a044f9e6a78d8dad5f73d08c34e4102a0420586ce2e28ed4f409" -dependencies = [ - "libc", - "log", - "names", - "reqwest", - "thiserror", -] - -[[package]] -name = "pyroscope_pprofrs" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3e9d063a1d882eb2459967e70839c84d107267a3f7a2cbe2bb8277820782e05" -dependencies = [ - "pprof", - "pyroscope", - "thiserror", -] - [[package]] name = "quanta" version = "0.10.1" @@ -3379,23 +3114,19 @@ dependencies = [ "http-body", "hyper", "hyper-rustls", - "hyper-tls", "ipnet", "js-sys", "log", "mime", - "native-tls", "once_cell", "percent-encoding", "pin-project-lite", "rustls 0.21.5", - "rustls-native-certs", "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", "tokio", - "tokio-native-tls", "tokio-rustls 0.24.1", "tokio-util", "tower-service", @@ -3502,18 +3233,6 @@ dependencies = [ "sct", ] -[[package]] -name = "rustls-native-certs" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" -dependencies = [ - "openssl-probe", - "rustls-pemfile", - "schannel", - "security-framework", -] - [[package]] name = "rustls-pemfile" version = "1.0.2" @@ -3554,15 +3273,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "schannel" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" -dependencies = [ - "windows-sys 0.42.0", -] - [[package]] name = "scopeguard" version = "1.1.0" @@ -3585,29 +3295,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "security-framework" -version = "2.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "semver" version = "1.0.16" @@ -3817,12 +3504,6 @@ dependencies = [ "syn 1.0.107", ] -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "static-files" version = "0.2.3" @@ -3840,12 +3521,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - [[package]] name = "strum" version = "0.24.1" @@ -3893,29 +3568,6 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" -[[package]] -name = "symbolic-common" -version = "9.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "800963ba330b09a2ae4a4f7c6392b81fbc2784099a98c1eac68c3437aa9382b2" -dependencies = [ - "debugid", - "memmap2", - "stable_deref_trait", - "uuid", -] - -[[package]] -name = "symbolic-demangle" -version = "9.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b940a1fdbc72bb3369e38714efe6cd332dbbe46d093cf03d668b9ac390d1ad0" -dependencies = [ - "cpp_demangle", - "rustc-demangle", - "symbolic-common", -] - [[package]] name = "syn" version = "1.0.107" @@ -3982,12 +3634,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "textwrap" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" - [[package]] name = "thiserror" version = "1.0.38" @@ -4125,16 +3771,6 @@ dependencies = [ "syn 2.0.37", ] -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.23.4" @@ -4514,12 +4150,6 @@ dependencies = [ "syn 1.0.107", ] -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "vergen" version = "8.1.3" @@ -4728,21 +4358,6 @@ dependencies = [ "windows_x86_64_msvc 0.39.0", ] -[[package]] -name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm 0.42.1", - "windows_aarch64_msvc 0.42.1", - "windows_i686_gnu 0.42.1", - "windows_i686_msvc 0.42.1", - "windows_x86_64_gnu 0.42.1", - "windows_x86_64_gnullvm 0.42.1", - "windows_x86_64_msvc 0.42.1", -] - [[package]] name = "windows-sys" version = "0.45.0" diff --git a/server/Cargo.toml b/server/Cargo.toml index 39e45e911..c6daf918c 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -66,8 +66,6 @@ log = "0.4" num_cpus = "1.15" once_cell = "1.17.1" prometheus = { version = "0.13", features = ["process"] } -pyroscope = { version = "0.5.3", optional = true } -pyroscope_pprofrs = { version = "0.2", optional = true } rand = "0.8" regex = "1.7.3" relative-path = { version = "1.7", features = ["serde"] } @@ -120,4 +118,4 @@ assets-url = "https://github.com/parseablehq/console/releases/download/v0.3.1/bu assets-sha1 = "6abd7b5ca5b9c832ff58b8450cffdc83dd7172bf" [features] -debug = ["pyroscope", "pyroscope_pprofrs"] +debug = [] diff --git a/server/src/handlers/http.rs b/server/src/handlers/http.rs index 832f5ea69..b9c1d7e03 100644 --- a/server/src/handlers/http.rs +++ b/server/src/handlers/http.rs @@ -74,14 +74,7 @@ pub async fn run_http( .configure(|cfg| configure_routes(cfg, oidc_client.clone())) .wrap(actix_web::middleware::Logger::default()) .wrap(actix_web::middleware::Compress::default()) - .wrap( - Cors::default() - .allow_any_header() - .allow_any_method() - .allow_any_origin() - .expose_any_header() - .supports_credentials(), - ) + .wrap(cross_origin_config()) }; let ssl_acceptor = match ( @@ -342,3 +335,11 @@ fn base_path() -> String { pub fn metrics_path() -> String { format!("{}/metrics", base_path()) } + +fn cross_origin_config() -> Cors { + if cfg!(feature = "debug") { + Cors::permissive() + } else { + Cors::default() + } +} diff --git a/server/src/handlers/livetail.rs b/server/src/handlers/livetail.rs index e09899fbf..a196fef6c 100644 --- a/server/src/handlers/livetail.rs +++ b/server/src/handlers/livetail.rs @@ -35,7 +35,7 @@ use arrow_flight::{ HandshakeResponse, PutResult, SchemaResult, Ticket, }; use tonic_web::GrpcWebLayer; -use tower_http::cors::{AllowHeaders, AllowMethods, AllowOrigin, CorsLayer}; +use tower_http::cors::CorsLayer; use crate::livetail::{Message, LIVETAIL}; use crate::metadata::STREAM_INFO; @@ -174,11 +174,7 @@ pub fn server() -> impl Future Option { .flatten() .find(|cookie| cookie.name() == SESSION_COOKIE_NAME) } + +fn cross_origin_config() -> CorsLayer { + if cfg!(feature = "debug") { + CorsLayer::very_permissive().allow_credentials(true) + } else { + CorsLayer::new() + } +} diff --git a/server/src/main.rs b/server/src/main.rs index 95499f621..3cf36b57d 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -21,11 +21,6 @@ use thread_priority::{ThreadBuilder, ThreadPriority}; use tokio::sync::oneshot; use tokio::sync::oneshot::error::TryRecvError; -#[cfg(feature = "debug")] -use pyroscope::PyroscopeAgent; -#[cfg(feature = "debug")] -use pyroscope_pprofrs::{pprof_backend, PprofConfig}; - use std::panic::{catch_unwind, AssertUnwindSafe}; use std::thread::{self, JoinHandle}; use std::time::Duration; @@ -52,11 +47,6 @@ mod validator; use option::CONFIG; -#[cfg(feature = "debug")] -const DEBUG_PYROSCOPE_URL: &str = "P_PROFILE_PYROSCOPE_URL"; -#[cfg(feature = "debug")] -const DEBUG_PYROSCOPE_TOKEN: &str = "P_PROFILE_PYROSCOPE_AUTH_TOKEN"; - #[actix_web::main] async fn main() -> anyhow::Result<()> { env_logger::init(); @@ -73,14 +63,6 @@ async fn main() -> anyhow::Result<()> { migration::run_migration(&CONFIG).await?; - #[cfg(feature = "debug")] - { - if std::env::var(DEBUG_PYROSCOPE_URL).is_ok() { - let url = std::env::var(DEBUG_PYROSCOPE_URL).ok(); - start_profiling(url.unwrap()); - } - } - if let Err(e) = metadata::STREAM_INFO.load(&*storage).await { log::warn!("could not populate local metadata. {:?}", e); } @@ -129,21 +111,6 @@ async fn main() -> anyhow::Result<()> { } } -#[cfg(feature = "debug")] -fn start_profiling(url: String) { - let auth_token = std::env::var(DEBUG_PYROSCOPE_TOKEN).unwrap_or_else(|_| "".to_string()); - - // Configure Pyroscope client. - let agent = PyroscopeAgent::builder(url, env!("CARGO_PKG_NAME").to_string()) - .auth_token(auth_token) - .backend(pprof_backend(PprofConfig::new().sample_rate(100))) - .build() - .unwrap(); - - // Start the Pyroscope client. - agent.start().unwrap(); -} - fn object_store_sync() -> (JoinHandle<()>, oneshot::Receiver<()>, oneshot::Sender<()>) { let (outbox_tx, outbox_rx) = oneshot::channel::<()>(); let (inbox_tx, inbox_rx) = oneshot::channel::<()>();