Public: anyone can read this; the crew can change it.
Main's full check has failed at 40-43m twice today (4:38, 9:04); make it pass… #16658
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/16655-main-s-full-check-has-failed-at-40-43m-t → main 0 commits fork
5 files
changed +58
−9
docs/OPERATING.md +1 −1
Diff not shown — a line 2,622 characters wide (limit 2,000). +1 −1
View filesrc/checks/run_tier.ts +2 −2
| @@ -220,11 +220,11 @@ export async function runTier(lane: LaneState, x: Execution): Promise<CheckOutco | ||
| 220 | 220 | for (const line of limitWarnings(manifest.limits)) write(line); |
| 221 | 221 | const cellCpus = resolveLimits("step", manifest.limits).cpus; |
| 222 | 222 | const shardCpus = checkShardCpus(cellCpus); |
| 223 | write(shardsLine(shardsInForce(app.db, shardCpus))); | |
| 223 | write(shardsLine(shardsInForce(app.db, shardCpus, x.tier === "verify"))); | |
| 224 | 224 | const env = childEnv({ |
| 225 | 225 | // The shard count an admin set (`core/capacity.ts`), else the |
| 226 | 226 | // default sized to what this check's cell holds, never the pod's. |
| 227 | ...capacityEnv(app.db, shardCpus), | |
| 227 | ...capacityEnv(app.db, shardCpus, x.tier === "verify"), | |
| 228 | 228 | CI: "1", |
| 229 | 229 | FORGE_URL: options.forgeUrl, |
| 230 | 230 | FORGE_CHECK: run.id, |
src/checks/tier_runner.ts +2 −2
| @@ -65,7 +65,7 @@ export async function tryRunner( | ||
| 65 | 65 | // The shard count an admin set reaches a runner's check as it does one run here (#14844); the |
| 66 | 66 | // default is sized as one run here is (`checkShardCpus`), never from the runner machine's CPUs. |
| 67 | 67 | const shardCpus = checkShardCpus(resolveLimits("step", manifest.limits).cpus); |
| 68 | write(shardsLine(shardsInForce(app.db, shardCpus))); | |
| 68 | write(shardsLine(shardsInForce(app.db, shardCpus, x.tier === "verify"))); | |
| 69 | 69 | const sent = await send(app, { |
| 70 | 70 | runId: x.runId, |
| 71 | 71 | repoId: repo.id, |
| @@ -82,7 +82,7 @@ export async function tryRunner( | ||
| 82 | 82 | ], |
| 83 | 83 | // Only the check's own variables cross, never the forge's; the runner adds its cell's. |
| 84 | 84 | env: { |
| 85 | ...capacityEnv(app.db, shardCpus), | |
| 85 | ...capacityEnv(app.db, shardCpus, x.tier === "verify"), | |
| 86 | 86 | CI: "1", |
| 87 | 87 | FORGE_URL: options.forgeUrl, |
| 88 | 88 | FORGE_CHECK: run.id, |
src/core/capacity.ts +22 −4
| @@ -736,8 +736,8 @@ export function edgeSigninOn(db: Database): boolean { | ||
| 736 | 736 | * default is sized from `cpus` — a check passes what its cell holds, so a |
| 737 | 737 | * small cell is never told the pod's count. |
| 738 | 738 | */ |
| 739 | export function capacityEnv(db: Database, cpus?: number): Record<string, string> { | |
| 740 | return { FORGE_CHECK_SHARDS: String(shardsInForce(db, cpus).count) }; | |
| 739 | export function capacityEnv(db: Database, cpus?: number, whole = false): Record<string, string> { | |
| 740 | return { FORGE_CHECK_SHARDS: String(shardsInForce(db, cpus, whole).count) }; | |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | /** Where the shard count in force came from: an admin's setting, the environment, or sized. */ |
| @@ -747,12 +747,30 @@ export type ShardsSource = "setting" | "environment" | "sized"; | ||
| 747 | 747 | * The shard count {@link capacityEnv} hands a check, and where it came from: an admin's value, |
| 748 | 748 | * else `FORGE_CHECK_SHARDS` in the forge's environment, else sized from `cpus`. |
| 749 | 749 | */ |
| 750 | export function shardsInForce(db: Database, cpus?: number): { count: number; source: ShardsSource } { | |
| 750 | export function shardsInForce( | |
| 751 | db: Database, | |
| 752 | cpus?: number, | |
| 753 | whole = false, | |
| 754 | ): { count: number; source: ShardsSource } { | |
| 751 | 755 | const stored = storedCapacity(db, "checks.shards"); |
| 752 | 756 | if (stored !== undefined) return { count: Number(stored), source: "setting" }; |
| 753 | 757 | const env = explicitDefault("checks.shards"); |
| 754 | 758 | if (env !== undefined) return { count: Number(env), source: "environment" }; |
| 755 | return { count: shardsForCpus(cpus ?? cpuLimit()), source: "sized" }; | |
| 759 | const sized = cpus ?? cpuLimit(); | |
| 760 | return { count: whole ? wholeSuiteShards(sized) : shardsForCpus(sized), source: "sized" }; | |
| 761 | } | |
| 762 | ||
| 763 | /** Most shards the whole suite takes by default: it runs alone, at the lowest priority (#16655). */ | |
| 764 | const WHOLE_SUITE_SHARDS_MAX = 8; | |
| 765 | ||
| 766 | /** | |
| 767 | * Shards by default for a run of every test file (the verify tier): `min(8, cpus)`, at least one. | |
| 768 | * Four shards left 10,000 s of work taking 40+ minutes on a cell of 16 CPUs; the pull's check | |
| 769 | * keeps {@link shardsForCpus}, since several of those run at once. | |
| 770 | */ | |
| 771 | export function wholeSuiteShards(cpus: number): number { | |
| 772 | const n = Math.floor(cpus); | |
| 773 | return Number.isFinite(n) ? Math.max(1, Math.min(WHOLE_SUITE_SHARDS_MAX, n)) : 1; | |
| 756 | 774 | } |
| 757 | 775 | |
| 758 | 776 | /** |
test/capacity-cpus.test.ts +31
| @@ -23,6 +23,7 @@ import { | ||
| 23 | 23 | provideCpusForTest, |
| 24 | 24 | setCapacity, |
| 25 | 25 | shardsForCpus, |
| 26 | wholeSuiteShards, | |
| 26 | 27 | } from "../src/core/capacity.ts"; |
| 27 | 28 | import { changedOf } from "../src/actions/capacity.ts"; |
| 28 | 29 | import { createUser } from "../src/core/users.ts"; |
| @@ -37,6 +38,36 @@ afterEach(() => { | ||
| 37 | 38 | provideCpusForTest(4); |
| 38 | 39 | }); |
| 39 | 40 | |
| 41 | describe("a run of the whole suite takes more shards than a pull's check", () => { | |
| 42 | test.each([ | |
| 43 | // cpus, shards | |
| 44 | [12, 8], // a 16-CPU cell's workers: 16 × 3/4 | |
| 45 | [8, 8], | |
| 46 | [4, 4], | |
| 47 | [1, 1], | |
| 48 | [80, 8], | |
| 49 | ])("%d CPUs: %d shards", (cpus, shards) => { | |
| 50 | expect(wholeSuiteShards(cpus)).toBe(shards); | |
| 51 | }); | |
| 52 | ||
| 53 | test("the verify tier is told 8 where a pull's check is told 4, and an admin's value wins for both", async () => { | |
| 54 | const dataDir = await mkdtemp(join(tmpdir(), "forge-capacity-whole-")); | |
| 55 | const app = createApp({ dataDir, port: 0 }); | |
| 56 | try { | |
| 57 | delete process.env.FORGE_CHECK_SHARDS; | |
| 58 | expect(capacityEnv(app.db, 12)).toEqual({ FORGE_CHECK_SHARDS: "4" }); | |
| 59 | expect(capacityEnv(app.db, 12, true)).toEqual({ FORGE_CHECK_SHARDS: "8" }); | |
| 60 | expect(capacityEnv(app.db, 2, true)).toEqual({ FORGE_CHECK_SHARDS: "2" }); | |
| 61 | process.env.FORGE_CHECK_SHARDS = "3"; | |
| 62 | expect(capacityEnv(app.db, 12, true)).toEqual({ FORGE_CHECK_SHARDS: "3" }); | |
| 63 | } finally { | |
| 64 | delete process.env.FORGE_CHECK_SHARDS; | |
| 65 | app.close(); | |
| 66 | await rm(dataDir, { recursive: true, force: true }); | |
| 67 | } | |
| 68 | }); | |
| 69 | }); | |
| 70 | ||
| 40 | 71 | describe("the defaults follow the CPUs", () => { |
| 41 | 72 | // By hand: shards = min(4, cpus); checks = floor(cpus / (shards * 3)), 1..16. |
| 42 | 73 | test.each([ |
new above
offline