-
Notifications
You must be signed in to change notification settings - Fork 329
Description
Problem
If a build does something silly like chmod 0444 ./subdir, attempts to clean up the build directory will fail with messages like:
# Removing /Users/julia/buildkite-agent/build/julia-master
🚨 Error: Failed to remove "/Users/julia/buildkite-agent/build/julia-master" (fstatat /Users/julia/buildkite-agent/build/julia-master/subdir/Manifest.toml: permission denied)
Then, subsequent git checkouts will fail (because that build directory is not empty) and the cleanup process will fail all over again. In our case, this happened due to a misconfigured find . -name \*.jl -exec chmod 0444 {} \; which found directories with names that ended in .jl instead of source code files like we intended. Unfortunately, this then required manual intervention on the build agent machines to clear out those bad permissions to allow the build to successfully go through.
Potential solution
I propose that when buildkite is attempting to clear out the build directory, that it should add execute (and write) permissions to all subdirectories, e.g. the equivalent of:
find . -type d -exec chmod u+wx {} \;
This will allow normal directory removal code to then process the repository. I don't think there's any valid usecase for allowing user code to create things that cannot be deleted like this, as it badly breaks the ability of buildkite to deal with the build directory.