Files
werewulf/hpcod/db/006-cluster-apps.sql
T
ilkerandClaude Opus 5 46de541a79 hpcod: the migration the last commit needed
a44fbc5 records a cluster's applications and reads them back, and the
table it does that in was never committed. It exists on the control
plane because it was applied there by hand, so everything works and a
second deployment from this repository would find nothing to insert
into - the failure arriving at allocation, on the first request after
the portal came up.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-22 10:25:31 +02:00

56 lines
2.7 KiB
PL/PgSQL

-- Which applications a cluster was built to hold.
--
-- The catalogue resolved these when the request was made: the portal turned
-- "gromacs" into a name and a registry URI, folded the GPU it needs into the
-- placement, and then threw the answer away. Nothing carried it any further.
-- provision.TFVars emitted no apps variable, so the tenant module took its
-- own `apps = []` default and every cluster was built with none of the
-- software it was asked for - while the portal, the Terraform module, the
-- vendor-data template and the apps Ansible role were all individually
-- correct. A chain that is right everywhere and connected nowhere.
--
-- Resolved, not requested. The rows hold the image URI rather than the
-- reference the user typed, so a cluster gets what was decided when it was
-- decided. Re-resolving at build time would mean a catalogue edited in the
-- minutes between allocation and provision changes what a cluster is, which
-- is the same class of bug as re-planning placement at build time.
--
-- Written in the allocating transaction, for the same reason the placement
-- is: a cluster holding an address but no record of what it is for would
-- provision as an empty scheduler and look healthy doing it.
BEGIN;
CREATE TABLE IF NOT EXISTS cluster_app (
cluster_serial_id bigint NOT NULL REFERENCES cluster(serial_id) ON DELETE CASCADE,
-- Preserves the order the catalogue resolved them in, so the tfvars and
-- the cloud-init document are byte-identical across a rebuild. A set
-- would be closer to the meaning and would make a rebuild look like a
-- change every time the rows came back in a different order.
ordinal int NOT NULL,
-- What /opt/apps/<name>.sif is called on the head.
name text NOT NULL CHECK (name <> ''),
-- Where apptainer pulls it from: oras://... or docker://...
image text NOT NULL CHECK (image <> ''),
PRIMARY KEY (cluster_serial_id, ordinal)
);
-- One entry per application per cluster. Asking for gromacs twice is a
-- request that should be refused rather than a cluster that pulls it twice.
CREATE UNIQUE INDEX IF NOT EXISTS cluster_app_name_unique
ON cluster_app (cluster_serial_id, name);
-- "Who is running gromacs" is a marketplace question, and it is the reason
-- this is a table rather than a jsonb column on cluster.
CREATE INDEX IF NOT EXISTS cluster_app_name_idx ON cluster_app (name);
COMMENT ON TABLE cluster_app IS
'Applications resolved from the catalogue at allocation, carried to the tenant module as the apps variable.';
COMMENT ON COLUMN cluster_app.image IS
'Registry URI as apptainer pull takes it. Resolved at request time and never re-resolved.';
COMMIT;