Repository navigation
Tenant-wide ceiling on live jobs, checked at acceptance (P2) - #2126
Conversation
…-fix # Conflicts: # CHANGELOG.md
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR2126Version: 🤖 Updated on each push. |
|
Review fixes pushed (head
Mutations (hand, restored): orphan term off fails 6 tests; old non-live-only orphan rule fails the duplicate test on both engines; |
|
Round-2 fixes pushed (head |
Refs #2121 (phase P2: the tenant-wide ceiling on live jobs, checked when a job is accepted). No queue (P3), no migration.
What is added
tenant { maxLiveJobs, reserved { people, pipelines, partner } }(optional, strict; the schema refuses floors that add up to more than the ceiling, soPUT /admin/compute/policydoes).TENANT_POLICY_DEFAULT= ceiling 20, floors 8 / 2 / 0, the same objectDEFAULT_COMPUTE_POLICY.tenantcarries; a stored policy without the key falls back to it, never to "unlimited".services/compute-tenant.ts:TENANT_COUNTS_SQL,tenantGuard(class, tenant),tenantFacts,tenantClassOf(by source word: cli/web people, pipeline pipelines, partner partner, swept rows and orphans other).createJobadds the tenant guard for EVERY source, after the class cap. The rule, in the hold's own statement:occupied + 1 + SUM over other classes of max(0, floor - occupied) <= ceiling. Occupancy is every live row plus one slot per row (live or not) that records an orphaned platform job.platform_busy(409), worded last (each guard is asked again in order after the refused hold, so the class cap wins over the tenant). It stops a pipeline run (STOPS_A_RUN) and ends the daily dispatcher's whole run (ENDS_THE_RUN); the admin route sentence is "NEMAR's share of the cluster is full right now; try again shortly."GET /admin/compute/statusgainstenantand the attention counttenant_over_ceiling;nemar admin compute statusprintsTenant: occupied/ceiling (people a, pipelines b, partner c, other d); the policy help documents the key. The live tenant sweep addstenant_live=<n> occupied=<n>/<ceiling>to its line and warns whentenant_liveexceeds the ceiling.Defaults and what they do
With the defaults the pipelines can burst to 12 (their own caps are 8 CPU + 4 GPU) only while nothing else occupies a slot, and people to 18. Runs and dry runs are clamped to the tenant room (
room.tenant_left,limited_by: tenant). The floors are unconditional.Tests
New
backend/test/compute-tenant-ceiling.test.ts(36 tests). Every guard case runs on BOTH engines (bun:sqlite and Miniflare D1): two and six requests racing for the last slots, a mixed crowd under a floor, a floor unconditional, a ceiling of 0, a floor equal to the ceiling, classes independent, acreatedjob counting, web and cli one class, the orphan term, the plan on both engines (live leg through a partial index, the orphan leg the one scan), the stored-policy-without-the-key fallback. Route level (real admin router and Tapis stand-in): (a) a CPU eligible run over a full ceiling makes 0 jobs, takes no hold, stops withplatform_busyand the stamp isrefused(with a control one slot higher that dispatches); the cron stops with the word; PUT refuses floors above the ceiling; the status route; the default 12-burst. Sweep, status CLI, contract and state unit tests updated.Mutation checks (one line each, restored): no guard (dev behavior): (a) and 14+ others fail (dispatched 5 instead of 0);
<=to<: race, floor and edge cases fail; floor term zeroed: floor and independence cases fail; orphan term off: orphan case and the plan pin fail; fallback made unlimited: the three fallback tests fail.Targeted runs: all
backend/test/compute*files plusadmin-credential-cascade(1599 pass, 0 fail), the compute CLI suites,adr-index,changelog-format, contract/state units andcontract-schemas;bun run typecheck,bun run lintclean. No migration, somigrations:d1-checkwas not run.Existing tests changed (the default ceiling is real)
Three suites made more live jobs than the default admits, so each lifts the ceiling for itself, with a comment:
compute-jobson Miniflare D1 (never reset),compute-pipeline-dispatch("never more than one tick's bound", 13 live jobs),compute-access-reporter(30 live jobs). One CLI run showed fourpool granttimeouts under machine load (5 s); they pass alone.Not verified / limits
bun test(epic-to-dev), and the remaining root CLI suites.compute_jobs; pinned by the plan test and written in the ADR.tenantkey as unreadable (strict reader, fails closed): write a policy without the key first.room.tenant_leftto a run response.For the third-party epic (#2116)
That branch rewrites the same
guardsblock ofcreateJob: whoever mergesdevinto it must keep the tenant guard and the pipeline guard (and theguardRefusalordering).Review round
Review fixes are listed per item in the comment below (head
b27fbee4). P2 is not in 0.10.33; this PR merges intodevafter the release PR, and its changelog sentence sits in the Unreleased compute bullet, ready to move.