Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions crates/mctx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,19 @@ impl Context {
&config,
)
.await;
let fetch_retries = match std::env::var("MINIMAL_FETCH_RETRIES") {
Ok(v) => v
.parse::<u32>()
.map_err(|e| RemoteError::Config(format!("MINIMAL_FETCH_RETRIES: {e}")))?,
Err(std::env::VarError::NotPresent) => self
.mfile
.cache
.fetch_retries
.unwrap_or(rcache::DEFAULT_FETCH_RETRIES),
// A set-but-garbled override must be loud, like any other bad value.
Err(e) => return Err(RemoteError::Config(format!("MINIMAL_FETCH_RETRIES: {e}"))),
};
let res = res.map(|rc| rc.with_fetch_retries(fetch_retries));
tracing::trace!("remote cache init took {:?}", start.elapsed());
res
}
Expand Down
5 changes: 5 additions & 0 deletions crates/mfile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,9 @@ pub struct CacheSettings {
/// Which index object the cache reader loads. Defaults to
/// [`IndexSourceMode::Auto`].
pub index_source: Option<IndexSourceMode>,
/// How many times a transient artifact-fetch failure is retried
/// (exponential backoff). Defaults to the reader's built-in value.
pub fetch_retries: Option<u32>,
}

/// Selects which remote-cache index object the reader loads.
Expand Down Expand Up @@ -1717,9 +1720,11 @@ mod tests {

[cache]
index_source = "root"
fetch_retries = 5
"#
))
.unwrap();
assert_eq!(mf.cache.fetch_retries, Some(5));
assert_eq!(mf.cache.index_source, Some(IndexSourceMode::Root));
assert_eq!(mf.cache_config(None).unwrap(), CacheConfig::GlobalIndex);
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion crates/rcache/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Remote cache implementation for fetching/uploading build artifacts over the network.

mod remote;
pub use remote::{Error, INDEX_FILENAME, IndexSource, RemoteCache};
pub use remote::{DEFAULT_FETCH_RETRIES, Error, INDEX_FILENAME, IndexSource, RemoteCache};

mod remote_writer;
pub use remote_writer::RemoteCacheWriter;
Expand Down
Loading