diff --git a/Cargo.lock b/Cargo.lock index 4f3f315330..8000ab3328 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8721,9 +8721,9 @@ dependencies = [ [[package]] name = "qorb" -version = "0.1.2" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d25f71eb7c5ba56a99f0721fd771b2503aa6de4ec73f0891f9b7ac115ca34723" +checksum = "9cd19ad8fae9abd8da01d8f435b633b567d53835cf3bce89d6f616617d10583c" dependencies = [ "anyhow", "async-trait", @@ -8741,6 +8741,7 @@ dependencies = [ "tokio-stream", "tokio-tungstenite 0.24.0", "tracing", + "usdt", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 84d93a1ec7..28e249f0ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -520,7 +520,7 @@ propolis_api_types = { git = "https://github.com/oxidecomputer/propolis", rev = propolis-client = { git = "https://github.com/oxidecomputer/propolis", rev = "86101eaf80b55e7f405b5cafe9b0de0e9f331656" } propolis-mock-server = { git = "https://github.com/oxidecomputer/propolis", rev = "86101eaf80b55e7f405b5cafe9b0de0e9f331656" } proptest = "1.5.0" -qorb = "0.1.2" +qorb = "0.2.0" quote = "1.0" rand = "0.8.5" rand_core = "0.6.4" diff --git a/nexus/db-queries/src/db/pool.rs b/nexus/db-queries/src/db/pool.rs index c42158a64f..61e1c91db1 100644 --- a/nexus/db-queries/src/db/pool.rs +++ b/nexus/db-queries/src/db/pool.rs @@ -89,12 +89,18 @@ impl Pool { let resolver = resolver.for_service(ServiceName::Cockroach); let connector = make_postgres_connector(log); - let policy = Policy::default(); - Pool { - inner: qorb::pool::Pool::new(resolver, connector, policy), - terminated: std::sync::atomic::AtomicBool::new(false), - } + let inner = match qorb::pool::Pool::new(resolver, connector, policy) { + Ok(pool) => { + debug!(log, "registered USDT probes"); + pool + } + Err(err) => { + error!(log, "failed to register USDT probes"); + err.into_inner() + } + }; + Pool { inner, terminated: std::sync::atomic::AtomicBool::new(false) } } /// Creates a new qorb-backed connection pool to a single instance of the @@ -110,12 +116,18 @@ impl Pool { let resolver = make_single_host_resolver(db_config); let connector = make_postgres_connector(log); - let policy = Policy::default(); - Pool { - inner: qorb::pool::Pool::new(resolver, connector, policy), - terminated: std::sync::atomic::AtomicBool::new(false), - } + let inner = match qorb::pool::Pool::new(resolver, connector, policy) { + Ok(pool) => { + debug!(log, "registered USDT probes"); + pool + } + Err(err) => { + error!(log, "failed to register USDT probes"); + err.into_inner() + } + }; + Pool { inner, terminated: std::sync::atomic::AtomicBool::new(false) } } /// Creates a new qorb-backed connection pool which returns an error @@ -134,15 +146,21 @@ impl Pool { let resolver = make_single_host_resolver(db_config); let connector = make_postgres_connector(log); - let policy = Policy { claim_timeout: tokio::time::Duration::from_millis(1), ..Default::default() }; - Pool { - inner: qorb::pool::Pool::new(resolver, connector, policy), - terminated: std::sync::atomic::AtomicBool::new(false), - } + let inner = match qorb::pool::Pool::new(resolver, connector, policy) { + Ok(pool) => { + debug!(log, "registered USDT probes"); + pool + } + Err(err) => { + error!(log, "failed to register USDT probes"); + err.into_inner() + } + }; + Pool { inner, terminated: std::sync::atomic::AtomicBool::new(false) } } /// Returns a connection from the pool diff --git a/nexus/src/app/sagas/common_storage/pantry_pool.rs b/nexus/src/app/sagas/common_storage/pantry_pool.rs index 9d1e76d27d..ae0ee3ce2a 100644 --- a/nexus/src/app/sagas/common_storage/pantry_pool.rs +++ b/nexus/src/app/sagas/common_storage/pantry_pool.rs @@ -84,9 +84,12 @@ impl backend::Connector for PantryConnector { pub(crate) fn make_pantry_connection_pool( qorb_resolver: &QorbResolver, ) -> pool::Pool { - pool::Pool::new( + match pool::Pool::new( qorb_resolver.for_service(ServiceName::CruciblePantry), Arc::new(PantryConnector), qorb::policy::Policy::default(), - ) + ) { + Ok(pool) => pool, + Err(e) => e.into_inner(), + } } diff --git a/oximeter/collector/src/lib.rs b/oximeter/collector/src/lib.rs index 6b10cf31cd..68fff4cbf0 100644 --- a/oximeter/collector/src/lib.rs +++ b/oximeter/collector/src/lib.rs @@ -344,11 +344,20 @@ impl Oximeter { )) }; - qorb::pool::Pool::new( + match qorb::pool::Pool::new( nexus_resolver, Arc::new(NexusConnector { log: log.clone() }), qorb::policy::Policy::default(), - ) + ) { + Ok(pool) => { + debug!(log, "registered USDT probes"); + pool + } + Err(err) => { + error!(log, "failed to register USDT probes"); + err.into_inner() + } + } }; let notify_nexus = || async { diff --git a/oximeter/db/src/client/mod.rs b/oximeter/db/src/client/mod.rs index 04caa13bd9..a4e73172cb 100644 --- a/oximeter/db/src/client/mod.rs +++ b/oximeter/db/src/client/mod.rs @@ -193,21 +193,39 @@ impl Client { )); let schema = Mutex::new(BTreeMap::new()); let request_timeout = DEFAULT_REQUEST_TIMEOUT; + let pool = match Pool::new( + http_resolver, + Arc::new(ReqwestConnector {}), + qorb::policy::Policy::default(), + ) { + Ok(pool) => { + debug!(log, "registered USDT probes"); + pool + } + Err(err) => { + error!(log, "failed to register USDT probes"); + err.into_inner() + } + }; + let native_pool = match Pool::new( + native_resolver, + Arc::new(native::connection::Connector), + qorb::policy::Policy::default(), + ) { + Ok(pool) => { + debug!(log, "registered USDT probes"); + pool + } + Err(err) => { + error!(log, "failed to register USDT probes"); + err.into_inner() + } + }; Self { _id: id, log, - source: ClientSource::Pool { - pool: DebugIgnore(Pool::new( - http_resolver, - Arc::new(ReqwestConnector {}), - qorb::policy::Policy::default(), - )), - }, - native_pool: DebugIgnore(Pool::new( - native_resolver, - Arc::new(native::connection::Connector), - Default::default(), - )), + source: ClientSource::Pool { pool: DebugIgnore(pool) }, + native_pool: DebugIgnore(native_pool), schema, request_timeout, } @@ -243,15 +261,25 @@ impl Client { let client = reqwest::Client::new(); let url = format!("http://{}", http_address); let schema = Mutex::new(BTreeMap::new()); + let native_pool = match Pool::new( + Box::new(SingleHostResolver::new(native_address)), + Arc::new(native::connection::Connector), + Default::default(), + ) { + Ok(pool) => { + debug!(log, "registered USDT probes"); + pool + } + Err(err) => { + error!(log, "failed to register USDT probes"); + err.into_inner() + } + }; Self { _id: id, log, source: ClientSource::Static(ReqwestClient { url, client }), - native_pool: DebugIgnore(Pool::new( - Box::new(SingleHostResolver::new(native_address)), - Arc::new(native::connection::Connector), - Default::default(), - )), + native_pool: DebugIgnore(native_pool), schema, request_timeout, } @@ -1787,7 +1815,7 @@ mod tests { .ping() .await .expect_err("Should fail to ping non-existent server"); - let Error::Connection(qorb::pool::Error::TimedOut) = &e else { + let Error::Connection(_) = &e else { panic!("Expected connection error, found {e:?}"); }; logctx.cleanup_successful(); diff --git a/workspace-hack/Cargo.toml b/workspace-hack/Cargo.toml index 24ae59bcc7..fb23570232 100644 --- a/workspace-hack/Cargo.toml +++ b/workspace-hack/Cargo.toml @@ -91,7 +91,7 @@ pkcs8 = { version = "0.10.2", default-features = false, features = ["encryption" postgres-types = { version = "0.2.8", default-features = false, features = ["with-chrono-0_4", "with-serde_json-1", "with-uuid-1"] } predicates = { version = "3.1.2" } proc-macro2 = { version = "1.0.87" } -qorb = { version = "0.1.2", features = ["qtop"] } +qorb = { version = "0.2.0", features = ["qtop"] } quote = { version = "1.0.37" } rand = { version = "0.8.5", features = ["small_rng"] } regex = { version = "1.11.0" } @@ -207,7 +207,7 @@ pkcs8 = { version = "0.10.2", default-features = false, features = ["encryption" postgres-types = { version = "0.2.8", default-features = false, features = ["with-chrono-0_4", "with-serde_json-1", "with-uuid-1"] } predicates = { version = "3.1.2" } proc-macro2 = { version = "1.0.87" } -qorb = { version = "0.1.2", features = ["qtop"] } +qorb = { version = "0.2.0", features = ["qtop"] } quote = { version = "1.0.37" } rand = { version = "0.8.5", features = ["small_rng"] } regex = { version = "1.11.0" }