Files
mesh-controller/internal/inventory/migrations/0017-what-a-machine-already-holds.sql
T
jschoubben 41f7c51032 Assign around what a machine already holds
The other half of ADR 0038, and what 04-ISSUES/028 was actually about.
A module can now avoid colliding with another module; until this it
could not avoid colliding with the mesh itself.

The substrate is not a module. A node raises it from the bundle it
carries before any mesh exists, so the control plane had never heard of
the store, the broker, or its own container — and handed a database
module 5432, which the store already had.

So the machine says. The host records what each resource binds,
distinguishing what it carried from what the mesh sent — a distinction
that already existed so the two never remove each other — and reports
the carried ones. The node states and this context writes, which is the
shape of every message between them.

What the declaration binds, not what is open. A machine's open ports are
a moving target, and assigning around them would mean a port that was
free when it was asked for and taken when it was used.

Replaced whole each time rather than merged: a machine that gave a port
back must be believed about that too, and a set that only grows keeps a
port reserved for something no longer there.

Tested against a real database, and the tests bite — removing the check
hands the module 20000, which the machine had said it holds.
2026-09-01 18:32:38 +02:00

13 lines
728 B
SQL

-- Ports a machine holds that the mesh did not assign.
--
-- novox/hq ADR 0038. The substrate is not a module: a node raises it from the bundle it carries
-- before any mesh exists, so the control plane has never heard of the store or the broker. Told
-- what they hold, it can put a module somewhere else; not told, it hands out a port one of them
-- has and finds out from a container runtime three layers down.
--
-- On the node rather than in the assignment table, because these are not assignments -- nothing
-- here chose them, and nothing here can move them. They are a fact about the machine, replaced
-- whole each time the machine states it.
alter table node add column carried_ports integer[] not null default '{}';