Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software:2222/vole.git

A free and open-source forge that lives in your Git repo.

Code

395 commit(s) on main

update readme Keenan Nemetz · 27m ago 32290114
history blame raw 1.2 KiB
1package agent
2
3// The runner's disk, as the only bound a job tree has.
4//
5// A job's workspace is a bind mount from the host: the runtime cannot quota it, and a
6// filesystem quota there would need root and a filesystem that supports one. What the
7// runner can promise is that it notices, so a job that writes without a bound costs
8// that job instead of the machine. The reserve is one statfs on the filesystem holding
9// --dir, checked while a command runs, and reported with the numbers.
10
11import (
12 "syscall"
13)
14
15// freeBytes reports how many bytes are available to this user on the filesystem
16// holding dir.
17func freeBytes(dir string) (int64, error) {
18 var st syscall.Statfs_t
19 if err := syscall.Statfs(dir, &st); err != nil {
20 return 0, err
21 }
22 return int64(st.Bavail) * int64(st.Bsize), nil
23}
24
25// diskLow reports whether the filesystem holding dir has less than reserve bytes
26// free. A reserve of zero disables the check, which is what a runner whose --dir is
27// on its own sized filesystem may choose.
28func diskLow(dir string, reserve int64) (free int64, low bool, err error) {
29 if reserve <= 0 || dir == "" {
30 return 0, false, nil
31 }
32 free, err = freeBytes(dir)
33 if err != nil {
34 return 0, false, err
35 }
36 return free, free < reserve, nil
37}
38