diff options
-rw-r--r-- | ops/modules/monorepo-gerrit.nix | 6 | ||||
-rw-r--r-- | tvix/castore/src/blobservice/object_store.rs | 24 | ||||
-rw-r--r-- | tvix/castore/src/directoryservice/object_store.rs | 23 | ||||
-rw-r--r-- | tvix/castore/src/lib.rs | 3 | ||||
-rw-r--r-- | tvix/glue/src/fetchers/mod.rs | 5 | ||||
-rw-r--r-- | tvix/glue/src/lib.rs | 3 | ||||
-rw-r--r-- | tvix/store/src/lib.rs | 3 | ||||
-rw-r--r-- | tvix/store/src/pathinfoservice/nix_http.rs | 11 |
8 files changed, 65 insertions, 13 deletions
diff --git a/ops/modules/monorepo-gerrit.nix b/ops/modules/monorepo-gerrit.nix index b335fe61d5bb..e9d48a6e35bc 100644 --- a/ops/modules/monorepo-gerrit.nix +++ b/ops/modules/monorepo-gerrit.nix @@ -97,6 +97,12 @@ in link = "https://cl.tvl.fyi/$1"; }; + # Auto-link links to monotonically increasing revisions/commits + commentlink.revision = { + match = "r/(\\d+)"; + link = "https://code.tvl.fyi/commit/?h=refs/r/$1"; + }; + # Configures integration with Keycloak, which then integrates with a # variety of backends. auth.type = "OAUTH"; diff --git a/tvix/castore/src/blobservice/object_store.rs b/tvix/castore/src/blobservice/object_store.rs index 10874af64011..317e8c18e893 100644 --- a/tvix/castore/src/blobservice/object_store.rs +++ b/tvix/castore/src/blobservice/object_store.rs @@ -1,5 +1,5 @@ use std::{ - collections::HashMap, + collections::{hash_map, HashMap}, io::{self, Cursor}, pin::pin, sync::Arc, @@ -298,10 +298,24 @@ impl ServiceBuilder for ObjectStoreBlobServiceConfig { instance_name: &str, _context: &CompositionContext, ) -> Result<Arc<dyn BlobService>, Box<dyn std::error::Error + Send + Sync + 'static>> { - let (object_store, path) = object_store::parse_url_opts( - &self.object_store_url.parse()?, - &self.object_store_options, - )?; + let opts = { + let mut opts: HashMap<&str, _> = self + .object_store_options + .iter() + .map(|(k, v)| (k.as_str(), v.as_str())) + .collect(); + + if let hash_map::Entry::Vacant(e) = + opts.entry(object_store::ClientConfigKey::UserAgent.as_ref()) + { + e.insert(crate::USER_AGENT); + } + + opts + }; + + let (object_store, path) = + object_store::parse_url_opts(&self.object_store_url.parse()?, opts)?; Ok(Arc::new(ObjectStoreBlobService { instance_name: instance_name.to_string(), object_store: Arc::new(object_store), diff --git a/tvix/castore/src/directoryservice/object_store.rs b/tvix/castore/src/directoryservice/object_store.rs index 1916e59eacaa..147a79cbfb42 100644 --- a/tvix/castore/src/directoryservice/object_store.rs +++ b/tvix/castore/src/directoryservice/object_store.rs @@ -1,3 +1,4 @@ +use std::collections::hash_map; use std::collections::HashMap; use std::sync::Arc; @@ -232,10 +233,24 @@ impl ServiceBuilder for ObjectStoreDirectoryServiceConfig { instance_name: &str, _context: &CompositionContext, ) -> Result<Arc<dyn DirectoryService>, Box<dyn std::error::Error + Send + Sync + 'static>> { - let (object_store, path) = object_store::parse_url_opts( - &self.object_store_url.parse()?, - &self.object_store_options, - )?; + let opts = { + let mut opts: HashMap<&str, _> = self + .object_store_options + .iter() + .map(|(k, v)| (k.as_str(), v.as_str())) + .collect(); + + if let hash_map::Entry::Vacant(e) = + opts.entry(object_store::ClientConfigKey::UserAgent.as_ref()) + { + e.insert(crate::USER_AGENT); + } + + opts + }; + + let (object_store, path) = + object_store::parse_url_opts(&self.object_store_url.parse()?, opts)?; Ok(Arc::new(ObjectStoreDirectoryService::new( instance_name.to_string(), Arc::new(object_store), diff --git a/tvix/castore/src/lib.rs b/tvix/castore/src/lib.rs index 93d06fd4582d..78018d8dfcbd 100644 --- a/tvix/castore/src/lib.rs +++ b/tvix/castore/src/lib.rs @@ -21,6 +21,9 @@ pub mod import; pub mod proto; pub mod tonic; +// Used as user agent in various HTTP Clients +const USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")); + pub use digests::{B3Digest, B3_LEN}; pub use errors::{DirectoryError, Error, ValidateNodeError}; pub use hashing_reader::{B3HashingReader, HashingReader}; diff --git a/tvix/glue/src/fetchers/mod.rs b/tvix/glue/src/fetchers/mod.rs index 8dd4fe8439fe..7050ad48f51a 100644 --- a/tvix/glue/src/fetchers/mod.rs +++ b/tvix/glue/src/fetchers/mod.rs @@ -186,7 +186,10 @@ impl<BS, DS, PS, NS> Fetcher<BS, DS, PS, NS> { nar_calculation_service: NS, ) -> Self { Self { - http_client: reqwest::Client::new(), + http_client: reqwest::Client::builder() + .user_agent(crate::USER_AGENT) + .build() + .expect("Client::new()"), blob_service, directory_service, path_info_service, diff --git a/tvix/glue/src/lib.rs b/tvix/glue/src/lib.rs index 320d1f6fede2..8f72424d59cc 100644 --- a/tvix/glue/src/lib.rs +++ b/tvix/glue/src/lib.rs @@ -7,6 +7,9 @@ pub mod tvix_store_io; mod fetchurl; +// Used as user agent in various HTTP Clients +const USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")); + #[cfg(test)] mod tests; diff --git a/tvix/store/src/lib.rs b/tvix/store/src/lib.rs index e1517609d51c..5f1642ce20e4 100644 --- a/tvix/store/src/lib.rs +++ b/tvix/store/src/lib.rs @@ -9,6 +9,9 @@ pub mod utils; #[cfg(test)] mod tests; +// Used as user agent in various HTTP Clients +const USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")); + // That's what the rstest_reuse README asks us do, and fails about being unable // to find rstest_reuse in crate root. #[cfg(test)] diff --git a/tvix/store/src/pathinfoservice/nix_http.rs b/tvix/store/src/pathinfoservice/nix_http.rs index e9b83dcf3551..a9e3e4b361f8 100644 --- a/tvix/store/src/pathinfoservice/nix_http.rs +++ b/tvix/store/src/pathinfoservice/nix_http.rs @@ -54,9 +54,14 @@ impl<BS, DS> NixHTTPPathInfoService<BS, DS> { Self { instance_name, base_url, - http_client: reqwest_middleware::ClientBuilder::new(reqwest::Client::new()) - .with(tvix_tracing::propagate::reqwest::tracing_middleware()) - .build(), + http_client: reqwest_middleware::ClientBuilder::new( + reqwest::Client::builder() + .user_agent(crate::USER_AGENT) + .build() + .expect("Client::new()"), + ) + .with(tvix_tracing::propagate::reqwest::tracing_middleware()) + .build(), blob_service, directory_service, |