Skip to content

Add fmd inventory to the database#10345

Open
smklein wants to merge 5 commits intoadd-fmd-inventoryfrom
add-fmd-inventory-db
Open

Add fmd inventory to the database#10345
smklein wants to merge 5 commits intoadd-fmd-inventoryfrom
add-fmd-inventory-db

Conversation

@smklein
Copy link
Copy Markdown
Collaborator

@smklein smklein commented Apr 29, 2026

Adds local-to-sled fault management info, from FMD, to the database.

Builds on #10283 , which propagated this info out of the Sled Agent API.

In the database, this propagates:

  • inv_fmd_status: The per-sled identification of whether or not fmd data was collected successfully
  • inv_fmd_host_cast: information about individual cases on a sled
  • inv_fmd_resource: information about individual resources that exist on a sled

smklein added 5 commits April 29, 2026 10:14
Adds three tables for persisting per-sled FMD data:
  inv_fmd_status      — per-sled outcome of FMD collection
  inv_fmd_host_case   — diagnosed cases (event payload as JSONB)
  inv_fmd_resource    — resources affected by cases

Bumps SCHEMA_VERSION to 254 with directory schema/crdb/inv-fmd. Adds
diesel table! entries, db-model structs, and From impls for the read
path. No callers yet — write/read/display follow in subsequent commits.
Wires the fmd field added to sled-agent's Inventory by the parent PR
through into Nexus's in-memory inventory representation. The collector
builder copies inventory.fmd verbatim. The DB read path will populate it
from the inv_fmd_* tables in a follow-on commit; for now, the read path
substitutes Available(empty) so existing tests round-trip cleanly.
Insert one InvFmdStatus row per sled in each inventory collection,
plus a row per case and resource when collection succeeded. Wire the
three tables into the existing prune transaction so old collections
clean up after themselves.
Loads inv_fmd_status, inv_fmd_host_case, and inv_fmd_resource for the
collection and reconstructs SledAgent.fmd. Status row's NULL
error_message indicates Available; non-NULL becomes Error{error}. A
missing status row falls back to Available with whatever cases/resources
were found (defensive, in case of historical data predating this PR).
Adds Display wrappers for FmdInventoryResult/FmdInventory/FmdHostCase/
FmdResource on the sled-agent types. Wires them into
nexus/types/src/inventory/display.rs::display_sleds so that
`omdb db inventory collections show` (and reconfigurator-cli scripts
that print sled inventories) include the FMD section.

The FmdHostCase event payload is the FMD nvlist serialized to JSON; we
intentionally don't interpret the schema, so it's pretty-printed
verbatim under the case heading.

Also seeds the representative test inventory (nexus/inventory examples)
with a single fault case + resource so the inv_fmd_* tables get rows
under test_representative_collection_populates_database. The
reconfigurator-cli golden outputs grow a 'fmd:' section accordingly.
@smklein smklein changed the title Add fmd inventory db Add fmd inventory to the database Apr 29, 2026
@smklein smklein marked this pull request as ready for review April 30, 2026 00:02
@smklein smklein requested review from hawkw and mergeconflict April 30, 2026 00:02
Comment on lines +4202 to +4203
// Load all FMD inventory rows. We expect at most ~tens of cases or
// resources per sled, so we don't bother paginating.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we get into some sort of trouble if this assumption is wrong (due to a bug, for example)?

Comment thread schema/crdb/dbinit.sql
);

CREATE TABLE IF NOT EXISTS omicron.public.inv_fmd_status (
inv_collection_id UUID NOT NULL,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (here and below): need a comment like:

-- (foreign key into `inv_collection` table)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants