The planner has been able to pick the right hypervisor and the right card
for a while. Nothing acted on it: /v1/plan printed the decision and threw it
away, and the cluster was then created from a tfvars whose cluster_id I read
off the running estate and typed in by hand.
POST /v1/clusters closes that. It takes exactly the path a dry run takes -
applications folded in, reservations subtracted, then planned - and writes
the result. Sharing the path is the point: if the two diverged, a dry run
would stop being worth running. What it does not do is provision. It settles
what the cluster is and leaves it in state "requested", because building
takes minutes and an HTTP request should not be holding the decision in
memory while it happens.
Also GET to list, DELETE to release, and adoption.
Adoption is not a convenience. c002 was built by hand and holds subnet and
MAC octet 2; the database knew nothing about it, so the allocator would
eventually have handed 2 to someone else and put two live clusters on the
same addresses. It is now recorded, and allocation measurably steps over it:
three requests in a row took 1, 3 and 4.
The store became an interface here so the handlers could be tested without a
PostgreSQL. What is worth checking at this layer is status codes and what
gets dropped in translation, and neither is a database question. An
infeasible request is 409 with the reasons attached, not 400: it is well
formed and may succeed tomorrow.
Verified against the live database and hv01, end to end:
POST 201, c001-5, compute1 holds 0000:01:00.0
POST again 409 "gpu: none present" - the card is promised to
a cluster that does not physically exist yet, so
only the reservation can say so
dry-run the same answer, which is the point
DELETE, POST again 201, address 1 recycled, name c001-6 - never c001-5
Three things the run found. The role had no privileges on the two tables
added in the last commit, because the first two were granted by hand and
nobody granted the rest - that is now a migration with default privileges,
so the next table cannot repeat it. A store failure was reported as 400,
which would have sent a caller rewriting a request that was never wrong.
And parseVMs split its input on every colon, cutting 0000:01:00.0 into
pieces and recording a card that does not exist; the test that caught it was
written for exactly that reason.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>