Remove folders with bad permissions#1980
Conversation
367a934 to
c855ff9
Compare
c855ff9 to
58a33ae
Compare
58a33ae to
d8a2a94
Compare
d8a2a94 to
9c0a0d4
Compare
9c0a0d4 to
b5febd3
Compare
chrisstaite
left a comment
There was a problem hiding this comment.
Reviewable status: 0 of 1 LGTMs obtained, and 0 of 9 files reviewed
nativelink-util/src/fs.rs line 375 at r1 (raw file):
for entry in WalkDir::new(&path) { let entry = match &entry {
Since you're ignoring the Err value the usual way to do this would be:
let Ok(entry) = &entry else {
debug!("Can't get into {entry:?}, assuming already deleted");
continue;
};
nativelink-util/src/fs.rs line 386 at r1 (raw file):
match std::fs::remove_dir_all(entry.path()) { Ok(()) => {} Err(e) => {
You could use a matcher here to avoid the nested if:
Err(e) if e.kind() == ErrorKind::PermissionDenied => {...}
e @ Err(_) => e.err_tip(|| format!("Removing {}", entry.path().display()))?,
nativelink-util/src/fs.rs line 403 at r1 (raw file):
} } if exists(&path)? {
Rather than the extra exists check, you could just call remove_dir_all and ignore the NotFound error.
b5febd3 to
11420c1
Compare
palfrey
left a comment
There was a problem hiding this comment.
Thanks, those are good catches. Made all those changes now.
Reviewable status: 0 of 1 LGTMs obtained, and 0 of 9 files reviewed, and pending CI: macos-15, ubuntu-24.04, NativeLink.com Cloud / Remote Cache / macos-15, NativeLink.com Cloud / Remote Cache / ubuntu-24.04, integration-tests, ubuntu-24.04 / stable, windows-2022 / stable, pre-commit-checks, Analyze (javascript-typescript), Analyze (python), Coverage, Publish image, Publish nativelink-worker-init, Publish nativelink-worker-lre-cc, Web Platform Deployment / macos-15, Web Platform Deployment / ubuntu-24.04, Bazel Dev / macos-15, Bazel Dev / ubuntu-24.04, Cargo Dev / macos-15, Cargo Dev / ubuntu-24.04, Installation / macos-15, Installation / ubuntu-24.04, buildstream, mongo, asan / ubuntu-24.04, Local / bazel / ubuntu-24.04, vale
11420c1 to
d4012b2
Compare
Description
Running
abseil-pygets the error2025-10-15T10:42:08.665910Z ERROR nativelink_worker::running_actions_manager: Error removing working directory, operation_id: Uuid(9843cbd8-8842-40bc-8055-4ed42ecdb1d5), err: Error { code: PermissionDenied, messages: ["Permission denied (os error 13)", "Could not remove working directory /tmp/nativelink/work/9843cbd8-8842-40bc-8055-4ed42ecdb1d5"] }The reason for this is it makes a directory called
test_create_file_fails_cleanupwith execute-only permissionsThe user is able to delete the file, but the standard Rust
remove_dir_allfails to do so, so I've written new code to walk the directory. Tried using the rm_rf crate first, but it has a bug in our test scenario.Type of change
Please delete options that aren't relevant.
How Has This Been Tested?
bazel test //...Checklist
bazel test //...passes locallygit amendsee some docsThis change is