Archived
A merge asks for a new module's build, and assign answered "no module of that name" until the build registered it, which read as a module nobody registered (hq issue 325). Keep every build request, tell a build in flight, a module known and not built, and an unknown name apart, and make an assignment made while the build runs when the build registers the module.
43 lines
2.3 KiB
SQL
43 lines
2.3 KiB
SQL
-- An assignment waits for its module's build (novox/hq issue 325).
|
|
--
|
|
-- A merge that adds a module asks for its build (issue 300), and the module is registered when the build's
|
|
-- outcome is taken in, minutes later. An `assign` in between was answered "no module of that name", which
|
|
-- read as "nobody registered it". The controller now keeps every build it asks for, so `assign` can tell a
|
|
-- build in flight from a module it never heard of, and an assignment made while the build runs is kept as
|
|
-- pending and made when the build registers the module, or ended with the reason when it does not.
|
|
|
|
-- Every build the controller asked for, whatever asked it: a merge, a plan's tier, a person's `build`, an
|
|
-- `assign` with build. Its outcome is the `build` row of the same id, written when the outcome is taken in;
|
|
-- an ask without one is still running, or was lost. not_asked is why a merge's ask of a new module could
|
|
-- not be made, and the id is then not a build's.
|
|
create table build_request (
|
|
id text primary key,
|
|
repository text not null,
|
|
seat text not null default '',
|
|
source_path text not null default '',
|
|
ref text not null default '',
|
|
commit_hash text not null default '',
|
|
asked_for text not null default '',
|
|
not_asked text,
|
|
asked_at timestamptz not null default now()
|
|
);
|
|
create index build_request_asked_at on build_request (asked_at);
|
|
|
|
-- An assignment kept until its module is registered. waiting until the build registers the module, then
|
|
-- applied (the assignment was made), refused (the assignment was refused then, with the refusal), expired
|
|
-- (the build failed, was not registered, or said nothing within its bound) or withdrawn (`unassign`).
|
|
create table pending_assignment (
|
|
id bigserial primary key,
|
|
node text not null,
|
|
module text not null,
|
|
build_id text not null,
|
|
repository text not null default '',
|
|
source_path text not null default '',
|
|
since timestamptz not null default now(),
|
|
state text not null default 'waiting'
|
|
check (state in ('waiting', 'applied', 'refused', 'expired', 'withdrawn')),
|
|
note text not null default '',
|
|
settled_at timestamptz
|
|
);
|
|
create unique index pending_assignment_waiting on pending_assignment (node, module) where state = 'waiting';
|