From bba64d876215e19fe588c72f168dc4b033581f6e Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sat, 29 Jun 2024 20:09:42 +0300 Subject: [PATCH] fix(tvix/castore/object_store): make query pairs object_store opts We previously called ObjectStoreBlobService::parse_url, which passes an empty list of options when constructing the ObjectStore. This is most likely not what we want. The more reasonable thing to do is pass along the query string (pairs) as options to `object_store::parse_url_opts`, and remove them from the plain URL we pass to object_store itself. Change-Id: Ic2cb1dca2a2980a863165d81baa3323a355cf3fe Reviewed-on: https://cl.tvl.fyi/c/depot/+/11897 Reviewed-by: Connor Brewster Autosubmit: flokli Tested-by: BuildkiteCI --- tvix/castore/src/blobservice/from_addr.rs | 7 +++++-- tvix/castore/src/directoryservice/from_addr.rs | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tvix/castore/src/blobservice/from_addr.rs b/tvix/castore/src/blobservice/from_addr.rs index f76592e50..b7e266c4e 100644 --- a/tvix/castore/src/blobservice/from_addr.rs +++ b/tvix/castore/src/blobservice/from_addr.rs @@ -42,10 +42,13 @@ pub async fn from_addr(uri: &str) -> Result, crate::Error> // parse it back as url, as Url::set_scheme() rejects some of the transitions we want to do. let trimmed_url = { let s = url.to_string(); - Url::parse(s.strip_prefix("objectstore+").unwrap()).unwrap() + let mut url = Url::parse(s.strip_prefix("objectstore+").unwrap()).unwrap(); + // trim the query pairs, they might contain credentials or local settings we don't want to send as-is. + url.set_query(None); + url }; Box::new( - ObjectStoreBlobService::parse_url(&trimmed_url) + ObjectStoreBlobService::parse_url_opts(&trimmed_url, url.query_pairs()) .map_err(|e| Error::StorageError(e.to_string()))?, ) } diff --git a/tvix/castore/src/directoryservice/from_addr.rs b/tvix/castore/src/directoryservice/from_addr.rs index 9aa01df17..999170dcd 100644 --- a/tvix/castore/src/directoryservice/from_addr.rs +++ b/tvix/castore/src/directoryservice/from_addr.rs @@ -75,10 +75,13 @@ pub async fn from_addr(uri: &str) -> Result, crate::Er // parse it back as url, as Url::set_scheme() rejects some of the transitions we want to do. let trimmed_url = { let s = url.to_string(); - Url::parse(s.strip_prefix("objectstore+").unwrap()).unwrap() + let mut url = Url::parse(s.strip_prefix("objectstore+").unwrap()).unwrap(); + // trim the query pairs, they might contain credentials or local settings we don't want to send as-is. + url.set_query(None); + url }; Box::new( - ObjectStoreDirectoryService::parse_url(&trimmed_url) + ObjectStoreDirectoryService::parse_url_opts(&trimmed_url, url.query_pairs()) .map_err(|e| Error::StorageError(e.to_string()))?, ) }