forge
Clone
https://git.tahinli.com/Tahinli/forge.git
0 watching0 forksRustAGPL-3.07.1 MiB490f099Tahinli7 hours ago322 commits
| 1 | //! The disk cap of a builtin job (`limits.job_disk_gb`). |
| 2 | //! |
| 3 | //! A rootless runner has no quotas, so the runner measures what the job wrote every few seconds |
| 4 | //! and stops it once that passes the cap. A job can overshoot by what it writes between two |
| 5 | //! checks. In subuid mode a dir the job made unreadable to the runner is not counted. |
| 6 | |
| 7 | use HashSet; |
| 8 | use fs; |
| 9 | use MetadataExt; |
| 10 | use PathBuf; |
| 11 | use Arc; |
| 12 | use ; |
| 13 | use ; |
| 14 | |
| 15 | use CancellationToken; |
| 16 | |
| 17 | /// How often the job's disk use is measured, at most. A measurement that takes long (a huge tree) |
| 18 | /// spaces the next one out to four times its own length, so the walk stays a small share of the |
| 19 | /// runner's time. |
| 20 | const INTERVAL: Duration = from_secs; |
| 21 | |
| 22 | /// The bytes allocated under `roots`. Symlinks are not followed, and a file with several hard |
| 23 | /// links counts once. Entries that can't be read are skipped. |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | /// Measures `roots` about every [`INTERVAL`] until it passes `cap` bytes, then sets `over` and cancels |
| 46 | /// `job`. Runs until it fires or is aborted. |
| 47 | pub async |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 |