about summary refs log tree commit diff
path: root/tvix/castore/src
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-06-29T17·09+0300
committerflokli <flokli@flokli.de>2024-06-29T19·23+0000
commitbba64d876215e19fe588c72f168dc4b033581f6e (patch)
tree2891c216b3b64dd3b7c3b835964bd368cbcc7335 /tvix/castore/src
parentd0ef6a50df6760702bf970c0cee71a5cdbff21b8 (diff)
fix(tvix/castore/object_store): make query pairs object_store opts r/8329
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 <cbrewster@hey.com>
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/castore/src')
-rw-r--r--tvix/castore/src/blobservice/from_addr.rs7
-rw-r--r--tvix/castore/src/directoryservice/from_addr.rs7
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 f76592e509f8..b7e266c4eaec 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<Box<dyn BlobService>, 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 9aa01df171d7..999170dcd13f 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<Box<dyn DirectoryService>, 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()))?,
             )
         }