Skip to content

Commit d14e835

Browse files
committed
schema: add fm_support_bundle_request table, per-variant data selection tables, and fm_case_id on support_bundle
Add migration SQL for fm_support_bundle_request and five per-variant data selection tables (reconfigurator, sled_cubby_info, sp_dumps, host_info, ereports). Add fm_case_id column to support_bundle. Update dbinit.sql, Diesel schema, and schema version.
1 parent 2baa491 commit d14e835

11 files changed

Lines changed: 206 additions & 3 deletions

File tree

nexus/db-model/src/schema_versions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::{collections::BTreeMap, sync::LazyLock};
1616
///
1717
/// This must be updated when you change the database schema. Refer to
1818
/// schema/crdb/README.adoc in the root of this repository for details.
19-
pub const SCHEMA_VERSION: Version = Version::new(240, 0, 0);
19+
pub const SCHEMA_VERSION: Version = Version::new(241, 0, 0);
2020

2121
/// List of all past database schema versions, in *reverse* order
2222
///
@@ -28,6 +28,7 @@ static KNOWN_VERSIONS: LazyLock<Vec<KnownVersion>> = LazyLock::new(|| {
2828
// | leaving the first copy as an example for the next person.
2929
// v
3030
// KnownVersion::new(next_int, "unique-dirname-with-the-sql-files"),
31+
KnownVersion::new(241, "fm-support-bundle-request"),
3132
KnownVersion::new(240, "multicast-drop-mvlan"),
3233
KnownVersion::new(239, "fm-alert-request"),
3334
KnownVersion::new(238, "fewer-nullable-columns"),

nexus/db-schema/src/schema.rs

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,6 +1590,7 @@ table! {
15901590

15911591
assigned_nexus -> Nullable<Uuid>,
15921592
user_comment -> Nullable<Text>,
1593+
fm_case_id -> Nullable<Uuid>,
15931594
}
15941595
}
15951596

@@ -3183,6 +3184,81 @@ table! {
31833184
}
31843185
}
31853186

3187+
// FM support bundle requests, stored per-sitrep like alert requests.
3188+
table! {
3189+
fm_support_bundle_request (sitrep_id, id) {
3190+
id -> Uuid,
3191+
sitrep_id -> Uuid,
3192+
requested_sitrep_id -> Uuid,
3193+
case_id -> Uuid,
3194+
reason -> Text,
3195+
}
3196+
}
3197+
3198+
// Per-variant data selection tables for fm_support_bundle_request.
3199+
// Each table corresponds to a BundleData variant. Row existence means
3200+
// "include this category in the bundle." No rows across any variant
3201+
// table means "collect everything."
3202+
3203+
// BundleData::Reconfigurator (unit variant, no filter columns)
3204+
table! {
3205+
fm_sb_req_reconfigurator (sitrep_id, request_id) {
3206+
sitrep_id -> Uuid,
3207+
request_id -> Uuid,
3208+
}
3209+
}
3210+
3211+
// BundleData::SledCubbyInfo (unit variant, no filter columns)
3212+
table! {
3213+
fm_sb_req_sled_cubby_info (sitrep_id, request_id) {
3214+
sitrep_id -> Uuid,
3215+
request_id -> Uuid,
3216+
}
3217+
}
3218+
3219+
// BundleData::SpDumps (unit variant, no filter columns)
3220+
table! {
3221+
fm_sb_req_sp_dumps (sitrep_id, request_id) {
3222+
sitrep_id -> Uuid,
3223+
request_id -> Uuid,
3224+
}
3225+
}
3226+
3227+
// BundleData::HostInfo(HashSet<SledSelection>)
3228+
table! {
3229+
fm_sb_req_host_info (sitrep_id, request_id) {
3230+
sitrep_id -> Uuid,
3231+
request_id -> Uuid,
3232+
all_sleds -> Bool,
3233+
sled_ids -> Array<Uuid>,
3234+
}
3235+
}
3236+
3237+
// BundleData::Ereports(EreportFilters)
3238+
table! {
3239+
fm_sb_req_ereports (sitrep_id, request_id) {
3240+
sitrep_id -> Uuid,
3241+
request_id -> Uuid,
3242+
start_time -> Nullable<Timestamptz>,
3243+
end_time -> Nullable<Timestamptz>,
3244+
only_serials -> Array<Text>,
3245+
only_classes -> Array<Text>,
3246+
}
3247+
}
3248+
3249+
// The per-variant tables use composite keys (sitrep_id, request_id)
3250+
// matching fm_support_bundle_request's (sitrep_id, id), so joinable!
3251+
// cannot be used (it requires single-column FKs). Queries must use
3252+
// explicit .on() clauses instead.
3253+
allow_tables_to_appear_in_same_query!(
3254+
fm_support_bundle_request,
3255+
fm_sb_req_reconfigurator,
3256+
fm_sb_req_sled_cubby_info,
3257+
fm_sb_req_sp_dumps,
3258+
fm_sb_req_host_info,
3259+
fm_sb_req_ereports,
3260+
);
3261+
31863262
table! {
31873263
trust_quorum_configuration (rack_id, epoch) {
31883264
rack_id -> Uuid,

schema/crdb/dbinit.sql

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3156,7 +3156,10 @@ CREATE TABLE IF NOT EXISTS omicron.public.support_bundle (
31563156
-- and later managing its storage.
31573157
assigned_nexus UUID,
31583158

3159-
user_comment TEXT
3159+
user_comment TEXT,
3160+
3161+
-- If this bundle was requested by an FM case, the case UUID.
3162+
fm_case_id UUID
31603163

31613164
);
31623165

@@ -7440,6 +7443,72 @@ CREATE INDEX IF NOT EXISTS
74407443
lookup_fm_alert_requests_for_case
74417444
ON omicron.public.fm_alert_request (sitrep_id, case_id);
74427445

7446+
CREATE TABLE IF NOT EXISTS omicron.public.fm_support_bundle_request (
7447+
-- Requested support bundle UUID.
7448+
id UUID NOT NULL,
7449+
-- UUID of the current sitrep that this request record is part of.
7450+
--
7451+
-- Note that this is *not* the sitrep in which the bundle was requested.
7452+
sitrep_id UUID NOT NULL,
7453+
-- UUID of the original sitrep in which the bundle was first requested.
7454+
requested_sitrep_id UUID NOT NULL,
7455+
-- UUID of the case to which this request belongs.
7456+
case_id UUID NOT NULL,
7457+
-- Human-readable reason for requesting the bundle.
7458+
reason TEXT NOT NULL,
7459+
7460+
PRIMARY KEY (sitrep_id, id)
7461+
);
7462+
7463+
CREATE INDEX IF NOT EXISTS
7464+
lookup_fm_support_bundle_requests_for_case
7465+
ON omicron.public.fm_support_bundle_request (sitrep_id, case_id);
7466+
7467+
-- Per-variant data selection tables for fm_support_bundle_request.
7468+
-- Row existence = "include this category in the bundle."
7469+
-- No rows in any variant table = "collect everything."
7470+
7471+
CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_reconfigurator (
7472+
sitrep_id UUID NOT NULL,
7473+
request_id UUID NOT NULL,
7474+
7475+
PRIMARY KEY (sitrep_id, request_id)
7476+
);
7477+
7478+
CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_sled_cubby_info (
7479+
sitrep_id UUID NOT NULL,
7480+
request_id UUID NOT NULL,
7481+
7482+
PRIMARY KEY (sitrep_id, request_id)
7483+
);
7484+
7485+
CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_sp_dumps (
7486+
sitrep_id UUID NOT NULL,
7487+
request_id UUID NOT NULL,
7488+
7489+
PRIMARY KEY (sitrep_id, request_id)
7490+
);
7491+
7492+
CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_host_info (
7493+
sitrep_id UUID NOT NULL,
7494+
request_id UUID NOT NULL,
7495+
all_sleds BOOL NOT NULL,
7496+
sled_ids UUID[] NOT NULL DEFAULT ARRAY[],
7497+
7498+
PRIMARY KEY (sitrep_id, request_id)
7499+
);
7500+
7501+
CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_ereports (
7502+
sitrep_id UUID NOT NULL,
7503+
request_id UUID NOT NULL,
7504+
start_time TIMESTAMPTZ,
7505+
end_time TIMESTAMPTZ,
7506+
only_serials TEXT[] NOT NULL DEFAULT ARRAY[],
7507+
only_classes TEXT[] NOT NULL DEFAULT ARRAY[],
7508+
7509+
PRIMARY KEY (sitrep_id, request_id)
7510+
);
7511+
74437512
/*
74447513
* List of datasets available to be sliced up and passed to VMMs for encrypted
74457514
* instance local storage.
@@ -8270,7 +8339,7 @@ INSERT INTO omicron.public.db_metadata (
82708339
version,
82718340
target_version
82728341
) VALUES
8273-
(TRUE, NOW(), NOW(), '240.0.0', NULL)
8342+
(TRUE, NOW(), NOW(), '241.0.0', NULL)
82748343
ON CONFLICT DO NOTHING;
82758344

82768345
COMMIT;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CREATE TABLE IF NOT EXISTS omicron.public.fm_support_bundle_request (
2+
-- Requested support bundle UUID.
3+
id UUID NOT NULL,
4+
-- UUID of the current sitrep that this request record is part of.
5+
--
6+
-- Note that this is *not* the sitrep in which the bundle was requested.
7+
sitrep_id UUID NOT NULL,
8+
-- UUID of the original sitrep in which the bundle was first requested.
9+
requested_sitrep_id UUID NOT NULL,
10+
-- UUID of the case to which this request belongs.
11+
case_id UUID NOT NULL,
12+
-- Human-readable reason for requesting the bundle.
13+
reason TEXT NOT NULL,
14+
15+
PRIMARY KEY (sitrep_id, id)
16+
);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CREATE INDEX IF NOT EXISTS
2+
lookup_fm_support_bundle_requests_for_case
3+
ON omicron.public.fm_support_bundle_request (sitrep_id, case_id);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_reconfigurator (
2+
sitrep_id UUID NOT NULL,
3+
request_id UUID NOT NULL,
4+
5+
PRIMARY KEY (sitrep_id, request_id)
6+
);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_sled_cubby_info (
2+
sitrep_id UUID NOT NULL,
3+
request_id UUID NOT NULL,
4+
5+
PRIMARY KEY (sitrep_id, request_id)
6+
);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_sp_dumps (
2+
sitrep_id UUID NOT NULL,
3+
request_id UUID NOT NULL,
4+
5+
PRIMARY KEY (sitrep_id, request_id)
6+
);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_host_info (
2+
sitrep_id UUID NOT NULL,
3+
request_id UUID NOT NULL,
4+
all_sleds BOOL NOT NULL,
5+
sled_ids UUID[] NOT NULL DEFAULT ARRAY[],
6+
7+
PRIMARY KEY (sitrep_id, request_id)
8+
);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_ereports (
2+
sitrep_id UUID NOT NULL,
3+
request_id UUID NOT NULL,
4+
start_time TIMESTAMPTZ,
5+
end_time TIMESTAMPTZ,
6+
only_serials TEXT[] NOT NULL DEFAULT ARRAY[],
7+
only_classes TEXT[] NOT NULL DEFAULT ARRAY[],
8+
9+
PRIMARY KEY (sitrep_id, request_id)
10+
);

0 commit comments

Comments
 (0)