Public: anyone can read this; the crew can change it.
The data volume has under 15% free #13844
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/13843-the-data-volume-has-under-15-free → main 1 commit fork
4 files
changed +11
−11
docs/features/disk-free.md +2 −2
| @@ -41,10 +41,10 @@ checkout and install. `dropCheckouts` (`src/apps/dormant_checkout.ts`) removes i | ||
| 41 | 41 | directories (`<env>/<sha7>`, `node_modules` and all) as it goes dormant, in the idle sweep and at |
| 42 | 42 | boot. Its data, home and build cache stay. |
| 43 | 43 | |
| 44 | ## A clone idle for a week goes whole (#13734) | |
| 44 | ## A clone idle for three days goes whole (#13734, #13843) | |
| 45 | 45 | |
| 46 | 46 | `sweepStaleClones` (`src/crew/orphans.ts`) removes a kept clone, sources and `.git`, whose `.git` |
| 47 | nothing has touched for seven days and no live run holds. The week is counted from `.git` alone, so | |
| 47 | nothing has touched for three days (it was seven; about 150 clones of ~150 MB were holding 22.8 GiB) and no live run holds. The window is counted from `.git` alone, so | |
| 48 | 48 | trimming `node_modules` at one day does not restart it. The remote is truth: a run fetches and |
| 49 | 49 | resets to it, and clones afresh when the directory is gone. |
| 50 | 50 |
src/crew/dispatch.ts +1 −1
| @@ -323,7 +323,7 @@ export async function startCrew( | ||
| 323 | 323 | }) |
| 324 | 324 | .then(() => sweepStaleClones(crewRoot(app.config.dataDir), isClaimed)) |
| 325 | 325 | .then(({ removed, kept }) => { |
| 326 | if (removed > 0) log.info("removed clones idle for a week", { count: removed }); | |
| 326 | if (removed > 0) log.info("removed clones idle for three days", { count: removed }); | |
| 327 | 327 | if (kept > 0) log.info("kept idle clones holding unpushed work", { count: kept }); |
| 328 | 328 | }) |
| 329 | 329 | .catch((error) => log.warn("clone sweep failed", { error: String(error) })); |
src/crew/orphans.ts +2 −2
| @@ -148,7 +148,7 @@ export async function sweepIdleDependencies( | ||
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** A kept clone goes whole once it has been idle this long (#13734). */ |
| 151 | export const CLONE_IDLE_MS = 7 * 86_400_000; | |
| 151 | export const CLONE_IDLE_MS = 3 * 86_400_000; | |
| 152 | 152 | |
| 153 | 153 | /** Run a fixed git argv in a clone; its stdout, or undefined when git fails. */ |
| 154 | 154 | async function gitOut(dir: string, args: string[]): Promise<string | undefined> { |
| @@ -183,7 +183,7 @@ export async function holdsUnpushedWork(dir: string): Promise<boolean> { | ||
| 183 | 183 | * Remove clones kept for an open issue or pull whose `.git` nothing has touched for `idleMs` and |
| 184 | 184 | * no live run holds, unless they hold work never pushed. Idleness reads `.git` only: trimming |
| 185 | 185 | * `node_modules` (`sweepIdleDependencies`) stamps the clone directory and must not restart the |
| 186 | * week. The remote is truth: a run fetches and resets to it, and clones afresh when the directory | |
| 186 | * window. The remote is truth: a run fetches and resets to it, and clones afresh when the directory | |
| 187 | 187 | * is missing. How many were removed and how many kept for unpushed work. |
| 188 | 188 | */ |
| 189 | 189 | export async function sweepStaleClones( |
test/orphan-clones.test.ts +6 −6
| @@ -61,7 +61,7 @@ describe("trimming idle clones' installed packages (#13514)", () => { | ||
| 61 | 61 | }); |
| 62 | 62 | }); |
| 63 | 63 | |
| 64 | describe("removing clones idle for a week (#13734)", () => { | |
| 64 | describe("removing clones idle for three days (#13734)", () => { | |
| 65 | 65 | const git = (cwd: string, ...args: string[]): void => { |
| 66 | 66 | const r = Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...args], { cwd }); |
| 67 | 67 | if (r.exitCode !== 0) throw new Error(r.stderr.toString()); |
| @@ -91,13 +91,13 @@ describe("removing clones idle for a week (#13734)", () => { | ||
| 91 | 91 | return dir; |
| 92 | 92 | }; |
| 93 | 93 | |
| 94 | test("only a week-idle, unheld, fully pushed clone goes", async () => { | |
| 94 | test("only a three-day-idle, unheld, fully pushed clone goes", async () => { | |
| 95 | 95 | const { sweepStaleClones } = await import("../src/crew/orphans.ts"); |
| 96 | 96 | const root = mkdtempSync(join(process.env.TMPDIR ?? tmpdir(), "orphans-")); |
| 97 | 97 | const stale = clone(root, "10"), recent = clone(root, "11"), live = clone(root, "12"); |
| 98 | await age(stale, 8); | |
| 99 | await age(live, 8); | |
| 100 | await age(recent, 2); | |
| 98 | await age(stale, 4); | |
| 99 | await age(live, 4); | |
| 100 | await age(recent, 1); | |
| 101 | 101 | expect(await sweepStaleClones(root, (d) => d === live)).toEqual({ removed: 1, kept: 0 }); |
| 102 | 102 | expect(existsSync(stale)).toBe(false); |
| 103 | 103 | expect(existsSync(recent)).toBe(true); |
| @@ -119,7 +119,7 @@ describe("removing clones idle for a week (#13734)", () => { | ||
| 119 | 119 | expect(readFileSync(join(dirty, "a"), "utf8")).toBe("edited"); |
| 120 | 120 | }); |
| 121 | 121 | |
| 122 | test("trimming node_modules does not restart the week", async () => { | |
| 122 | test("trimming node_modules does not restart the clock", async () => { | |
| 123 | 123 | const { sweepStaleClones, sweepIdleDependencies } = await import("../src/crew/orphans.ts"); |
| 124 | 124 | const root = mkdtempSync(join(process.env.TMPDIR ?? tmpdir(), "orphans-")); |
| 125 | 125 | const dir = clone(root, "10"); |
new above
offline