Skip to content

Commit a11968f

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 1f1c514 commit a11968f

11 files changed

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

schema/crdb/dbinit.sql

Lines changed: 69 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,70 @@ 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+
7458+
PRIMARY KEY (sitrep_id, id)
7459+
);
7460+
7461+
CREATE INDEX IF NOT EXISTS
7462+
lookup_fm_support_bundle_requests_for_case
7463+
ON omicron.public.fm_support_bundle_request (sitrep_id, case_id);
7464+
7465+
-- Per-variant data selection tables for fm_support_bundle_request.
7466+
-- Row existence = "include this category in the bundle."
7467+
-- No rows in any variant table = "collect everything."
7468+
7469+
CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_reconfigurator (
7470+
sitrep_id UUID NOT NULL,
7471+
request_id UUID NOT NULL,
7472+
7473+
PRIMARY KEY (sitrep_id, request_id)
7474+
);
7475+
7476+
CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_sled_cubby_info (
7477+
sitrep_id UUID NOT NULL,
7478+
request_id UUID NOT NULL,
7479+
7480+
PRIMARY KEY (sitrep_id, request_id)
7481+
);
7482+
7483+
CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_sp_dumps (
7484+
sitrep_id UUID NOT NULL,
7485+
request_id UUID NOT NULL,
7486+
7487+
PRIMARY KEY (sitrep_id, request_id)
7488+
);
7489+
7490+
CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_host_info (
7491+
sitrep_id UUID NOT NULL,
7492+
request_id UUID NOT NULL,
7493+
all_sleds BOOL NOT NULL,
7494+
sled_ids UUID[] NOT NULL DEFAULT ARRAY[],
7495+
7496+
PRIMARY KEY (sitrep_id, request_id)
7497+
);
7498+
7499+
CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_ereports (
7500+
sitrep_id UUID NOT NULL,
7501+
request_id UUID NOT NULL,
7502+
start_time TIMESTAMPTZ,
7503+
end_time TIMESTAMPTZ,
7504+
only_serials TEXT[] NOT NULL DEFAULT ARRAY[],
7505+
only_classes TEXT[] NOT NULL DEFAULT ARRAY[],
7506+
7507+
PRIMARY KEY (sitrep_id, request_id)
7508+
);
7509+
74437510
/*
74447511
* List of datasets available to be sliced up and passed to VMMs for encrypted
74457512
* instance local storage.
@@ -8270,7 +8337,7 @@ INSERT INTO omicron.public.db_metadata (
82708337
version,
82718338
target_version
82728339
) VALUES
8273-
(TRUE, NOW(), NOW(), '240.0.0', NULL)
8340+
(TRUE, NOW(), NOW(), '241.0.0', NULL)
82748341
ON CONFLICT DO NOTHING;
82758342

82768343
COMMIT;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
PRIMARY KEY (sitrep_id, id)
13+
);
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)