It was enabled - 168 cores offered from 28, 655 GiB from 504 - but only because I edited sites.yaml on the server and restarted the service. So changing it needed a shell, an editor and a restart, which means it needed whoever had those rather than whoever had the judgement. It is a judgement about how much of the hardware to promise, it moves with load, and it belongs where the person making it can reach it. It is now a row per site, set from the Sites page by an administrator, and it takes effect on the next discovery sweep rather than the next restart. The ratio is applied after discovery instead of inside the provider, which is what makes that possible - and because it recomputes from the physical core and memory counts rather than from whatever Cores already held, applying it twice gives the same answer as applying it once. Without that the provider's own default would compound with it. The file stays as the default. A site with no row shows what the catalogue gave it, read back from the numbers rather than claimed, and says so: "from the site catalogue - nobody has set this" against "set by ilker". One authority at a time, and the page says which. The rules the config loader already enforced are enforced here too, in the database rather than in the handler: a policy that reads as off cannot still multiply, and turning it off resets the ratios instead of leaving numbers behind that would take effect again for whoever turns it back on. Memory is capped at 8x where CPU is capped at 64x, because oversubscribed cores make jobs slow and oversubscribed memory makes them die. Also fixed a test that was crying wolf: the public-page leak check matched bare substrings, so adding a "label" rule to the stylesheet looked like the tenant name "lab" appearing on the front door. It matches word boundaries now - a test that raises false alarms gets weakened until it stops catching anything. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
39 lines
1.7 KiB
PL/PgSQL
39 lines
1.7 KiB
PL/PgSQL
-- Oversubscription policy, per site.
|
|
--
|
|
-- It started in sites.yaml, which is the wrong home for it. A ratio is not
|
|
-- a property of the site the way its endpoint is: it is a judgement about
|
|
-- how much the hardware can be promised, it changes with load, and it is
|
|
-- exactly the thing an operator wants to adjust without editing a file on
|
|
-- a server and restarting a service.
|
|
--
|
|
-- The file value becomes the default. Once a row exists here it is what is
|
|
-- in effect, and the portal says so, so there is one authority at a time
|
|
-- rather than two that can disagree silently.
|
|
|
|
BEGIN;
|
|
|
|
CREATE TABLE IF NOT EXISTS site_policy (
|
|
site text PRIMARY KEY,
|
|
|
|
oversubscribe boolean NOT NULL DEFAULT false,
|
|
-- Stored as numeric, not float: these are written by hand and read back
|
|
-- to be shown, and 6.0 should come back as 6.0.
|
|
cpu_overcommit numeric(4,2) NOT NULL DEFAULT 1.0 CHECK (cpu_overcommit >= 1.0 AND cpu_overcommit <= 64.0),
|
|
mem_overcommit numeric(4,2) NOT NULL DEFAULT 1.0 CHECK (mem_overcommit >= 1.0 AND mem_overcommit <= 8.0),
|
|
|
|
-- The same contradiction the config loader refuses: a policy that reads
|
|
-- as off must not still inflate the site.
|
|
CONSTRAINT off_means_off CHECK (
|
|
oversubscribe OR (cpu_overcommit = 1.0 AND mem_overcommit = 1.0)),
|
|
|
|
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
updated_by text NOT NULL
|
|
);
|
|
|
|
COMMENT ON TABLE site_policy IS
|
|
'Current oversubscription policy. Overrides the ratio in the site catalogue.';
|
|
COMMENT ON COLUMN site_policy.mem_overcommit IS
|
|
'Capped lower than CPU on purpose: oversubscribed cores make jobs slow, oversubscribed memory makes them die.';
|
|
|
|
COMMIT;
|