buildkite / buildkite/agent

Buildkite checkout fails, and deletes most of the repo, if any user-owned files in the checkout path are non-writable

Open
#1,368 5 comments 2 reactions 0 assignees View on GitHub
git
Dominant language
Go
Stars
1.1k
Forks
378
Avg merge
2d 6h
Merged PRs (30d)
74

Description

Agent User: `buildkite-agent`
Example Checkout path: `/var/lib/buildkite-agent/software`
Read-only File: `/var/lib/buildkite-agent/software/tmp/file`

```
ls -l /var/lib/buildkite-agent/software/tmp/file
-r-xr-xr-x 1 buildkite-agent buildkite-agent 186824 Jan 11 11:49 /var/lib/buildkite-agent/software/tmp/file
```

In our case, a previous build rsyncs to the checkout directory, and writes `tmp/file`. While the owner is `buildkite-agent`, the permissions are set as `u+rx` and `u-w`, aka the file is "read-only".

On the next build will fail to `git clean`, and then it will try to delete the whole repo (and fail), and then try to clone (and fail). However, the user actually owns those files, and buildkite-agent could simply chmod o+w any files that it tries to delete, or `rm -f `. Assuming buildkite-agent is using a filesystem interface in golang, it's likely some argument would have to change for it to delete write-only files.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the checkout cleanup path that runs git clean before the repository deletion and clone fallback, using the reported checkout path and non-writable tmp/file example as the reproduction case. Done means a user-owned read-only file can be removed during cleanup and the checkout proceeds without deleting or recloning the repository.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.