Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow sccache keep running after hitting rate limit during check #1557

Merged
merged 3 commits into from
Jan 12, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ bincode = "1"
blake3 = "1"
byteorder = "1.0"
bytes = "1"
opendal = { version= "0.24", optional=true }
opendal = { version= "0.24.6", optional=true }
reqsign = {version="0.7.3", optional=true}
chrono = { version = "0.4.23", optional = true }
clap = { version = "4.0.32", features = ["derive", "env", "wrap_help"] }
Expand Down
4 changes: 4 additions & 0 deletions docs/GHA.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ This cache type will needs token like `ACTIONS_CACHE_URL` and `ACTIONS_RUNTIME_T
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
```

## Behavior

In case sccache reaches the rate limit of the service, the build will continue but the storage might not be performed.
14 changes: 13 additions & 1 deletion src/cache/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,18 @@ impl Storage for opendal::Operator {
Ok(_) => (),
// Read not exist file with not found is ok.
Err(err) if err.kind() == ErrorKind::ObjectNotFound => (),
// Tricky Part.
//
// We tolerate rate limited here to make sccache keep running.
Xuanwo marked this conversation as resolved.
Show resolved Hide resolved
// For the worse case, we will miss all the cache.
//
// In some super rare cases, user could configure storage in wrong
// and hitting other services rate limit. There are few things we
// can do, so we will print our the error here to make users know
// about it.
Err(err) if err.kind() == ErrorKind::ObjectRateLimited => {
eprintln!("cache storage read check: {err:?}, but we decide to keep running")
}
Err(err) => bail!("cache storage failed to read: {:?}", err),
};

Expand All @@ -405,7 +417,7 @@ impl Storage for opendal::Operator {
Err(err) if err.kind() == ErrorKind::ObjectAlreadyExists => true,
// Toralte all other write errors because we can do read as least.
Err(err) => {
warn!("storage write check failed: {err:?}");
eprintln!("storage write check failed: {err:?}");
false
}
};
Expand Down