Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nexus/db-model/src/schema_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::{collections::BTreeMap, sync::LazyLock};
///
/// This must be updated when you change the database schema. Refer to
/// schema/crdb/README.adoc in the root of this repository for details.
pub const SCHEMA_VERSION: Version = Version::new(240, 0, 0);
pub const SCHEMA_VERSION: Version = Version::new(241, 0, 0);

/// List of all past database schema versions, in *reverse* order
///
Expand All @@ -28,6 +28,7 @@ static KNOWN_VERSIONS: LazyLock<Vec<KnownVersion>> = LazyLock::new(|| {
// | leaving the first copy as an example for the next person.
// v
// KnownVersion::new(next_int, "unique-dirname-with-the-sql-files"),
KnownVersion::new(241, "fm-support-bundle-request"),
KnownVersion::new(240, "multicast-drop-mvlan"),
KnownVersion::new(239, "fm-alert-request"),
KnownVersion::new(238, "fewer-nullable-columns"),
Expand Down
75 changes: 75 additions & 0 deletions nexus/db-schema/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,7 @@ table! {

assigned_nexus -> Nullable<Uuid>,
user_comment -> Nullable<Text>,
fm_case_id -> Nullable<Uuid>,
}
}

Expand Down Expand Up @@ -3183,6 +3184,80 @@ table! {
}
}

// FM support bundle requests, stored per-sitrep like alert requests.
table! {
fm_support_bundle_request (sitrep_id, id) {
id -> Uuid,
sitrep_id -> Uuid,
requested_sitrep_id -> Uuid,
case_id -> Uuid,
}
}

// Per-variant data selection tables for fm_support_bundle_request.
// Each table corresponds to a BundleData variant. Row existence means
// "include this category in the bundle." No rows across any variant
// table means "collect everything."

// BundleData::Reconfigurator (unit variant, no filter columns)
table! {
fm_sb_req_reconfigurator (sitrep_id, request_id) {
sitrep_id -> Uuid,
request_id -> Uuid,
}
}

// BundleData::SledCubbyInfo (unit variant, no filter columns)
table! {
fm_sb_req_sled_cubby_info (sitrep_id, request_id) {
sitrep_id -> Uuid,
request_id -> Uuid,
}
}

// BundleData::SpDumps (unit variant, no filter columns)
table! {
fm_sb_req_sp_dumps (sitrep_id, request_id) {
sitrep_id -> Uuid,
request_id -> Uuid,
}
}

// BundleData::HostInfo(HashSet<SledSelection>)
table! {
fm_sb_req_host_info (sitrep_id, request_id) {
sitrep_id -> Uuid,
request_id -> Uuid,
all_sleds -> Bool,
sled_ids -> Array<Uuid>,
}
}

// BundleData::Ereports(EreportFilters)
table! {
fm_sb_req_ereports (sitrep_id, request_id) {
sitrep_id -> Uuid,
request_id -> Uuid,
start_time -> Nullable<Timestamptz>,
end_time -> Nullable<Timestamptz>,
only_serials -> Array<Text>,
only_classes -> Array<Text>,
}
}

// The per-variant tables use composite keys (sitrep_id, request_id)
// matching fm_support_bundle_request's (sitrep_id, id), so joinable!
// cannot be used (it requires single-column FKs). Queries must use
// explicit .on() clauses instead.
allow_tables_to_appear_in_same_query!(
fm_support_bundle_request,
fm_sb_req_reconfigurator,
fm_sb_req_sled_cubby_info,
fm_sb_req_sp_dumps,
fm_sb_req_host_info,
fm_sb_req_ereports,
);

table! {
trust_quorum_configuration (rack_id, epoch) {
rack_id -> Uuid,
Expand Down
71 changes: 69 additions & 2 deletions schema/crdb/dbinit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3156,7 +3156,10 @@ CREATE TABLE IF NOT EXISTS omicron.public.support_bundle (
-- and later managing its storage.
assigned_nexus UUID,

user_comment TEXT
user_comment TEXT,

-- If this bundle was requested by an FM case, the case UUID.
fm_case_id UUID

);

Expand Down Expand Up @@ -7440,6 +7443,70 @@ CREATE INDEX IF NOT EXISTS
lookup_fm_alert_requests_for_case
ON omicron.public.fm_alert_request (sitrep_id, case_id);

CREATE TABLE IF NOT EXISTS omicron.public.fm_support_bundle_request (
-- Requested support bundle UUID.
id UUID NOT NULL,
-- UUID of the current sitrep that this request record is part of.
--
-- Note that this is *not* the sitrep in which the bundle was requested.
sitrep_id UUID NOT NULL,
-- UUID of the original sitrep in which the bundle was first requested.
requested_sitrep_id UUID NOT NULL,
-- UUID of the case to which this request belongs.
case_id UUID NOT NULL,

PRIMARY KEY (sitrep_id, id)
);

CREATE INDEX IF NOT EXISTS
lookup_fm_support_bundle_requests_for_case
ON omicron.public.fm_support_bundle_request (sitrep_id, case_id);

-- Per-variant data selection tables for fm_support_bundle_request.
-- Row existence = "include this category in the bundle."
-- No rows in any variant table = "collect everything."

CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_reconfigurator (
sitrep_id UUID NOT NULL,
request_id UUID NOT NULL,

PRIMARY KEY (sitrep_id, request_id)
);

CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_sled_cubby_info (
sitrep_id UUID NOT NULL,
request_id UUID NOT NULL,

PRIMARY KEY (sitrep_id, request_id)
);

CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_sp_dumps (
sitrep_id UUID NOT NULL,
request_id UUID NOT NULL,

PRIMARY KEY (sitrep_id, request_id)
);

CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_host_info (
sitrep_id UUID NOT NULL,
request_id UUID NOT NULL,
all_sleds BOOL NOT NULL,
sled_ids UUID[] NOT NULL DEFAULT ARRAY[],

PRIMARY KEY (sitrep_id, request_id)
);

CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_ereports (
sitrep_id UUID NOT NULL,
request_id UUID NOT NULL,
start_time TIMESTAMPTZ,
end_time TIMESTAMPTZ,
only_serials TEXT[] NOT NULL DEFAULT ARRAY[],
only_classes TEXT[] NOT NULL DEFAULT ARRAY[],

PRIMARY KEY (sitrep_id, request_id)
);

/*
* List of datasets available to be sliced up and passed to VMMs for encrypted
* instance local storage.
Expand Down Expand Up @@ -8270,7 +8337,7 @@ INSERT INTO omicron.public.db_metadata (
version,
target_version
) VALUES
(TRUE, NOW(), NOW(), '240.0.0', NULL)
(TRUE, NOW(), NOW(), '241.0.0', NULL)
ON CONFLICT DO NOTHING;

COMMIT;
13 changes: 13 additions & 0 deletions schema/crdb/fm-support-bundle-request/up1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CREATE TABLE IF NOT EXISTS omicron.public.fm_support_bundle_request (
-- Requested support bundle UUID.
id UUID NOT NULL,
-- UUID of the current sitrep that this request record is part of.
--
-- Note that this is *not* the sitrep in which the bundle was requested.
sitrep_id UUID NOT NULL,
-- UUID of the original sitrep in which the bundle was first requested.
requested_sitrep_id UUID NOT NULL,
-- UUID of the case to which this request belongs.
case_id UUID NOT NULL,
PRIMARY KEY (sitrep_id, id)
);
3 changes: 3 additions & 0 deletions schema/crdb/fm-support-bundle-request/up2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CREATE INDEX IF NOT EXISTS
lookup_fm_support_bundle_requests_for_case
ON omicron.public.fm_support_bundle_request (sitrep_id, case_id);
2 changes: 2 additions & 0 deletions schema/crdb/fm-support-bundle-request/up2.verify.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- DO NOT EDIT. Generated by test_migration_verification_files.
SELECT CAST(IF((SELECT true WHERE EXISTS (SELECT index_name FROM omicron.crdb_internal.table_indexes WHERE descriptor_name = 'fm_support_bundle_request' AND index_name = 'lookup_fm_support_bundle_requests_for_case')),'true','Schema change verification failed: index lookup_fm_support_bundle_requests_for_case on table fm_support_bundle_request does not exist') AS BOOL);
6 changes: 6 additions & 0 deletions schema/crdb/fm-support-bundle-request/up3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_reconfigurator (
sitrep_id UUID NOT NULL,
request_id UUID NOT NULL,

PRIMARY KEY (sitrep_id, request_id)
);
6 changes: 6 additions & 0 deletions schema/crdb/fm-support-bundle-request/up4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_sled_cubby_info (
sitrep_id UUID NOT NULL,
request_id UUID NOT NULL,

PRIMARY KEY (sitrep_id, request_id)
);
6 changes: 6 additions & 0 deletions schema/crdb/fm-support-bundle-request/up5.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_sp_dumps (
sitrep_id UUID NOT NULL,
request_id UUID NOT NULL,

PRIMARY KEY (sitrep_id, request_id)
);
8 changes: 8 additions & 0 deletions schema/crdb/fm-support-bundle-request/up6.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_host_info (
sitrep_id UUID NOT NULL,
request_id UUID NOT NULL,
all_sleds BOOL NOT NULL,
sled_ids UUID[] NOT NULL DEFAULT ARRAY[],

PRIMARY KEY (sitrep_id, request_id)
);
10 changes: 10 additions & 0 deletions schema/crdb/fm-support-bundle-request/up7.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CREATE TABLE IF NOT EXISTS omicron.public.fm_sb_req_ereports (
sitrep_id UUID NOT NULL,
request_id UUID NOT NULL,
start_time TIMESTAMPTZ,
end_time TIMESTAMPTZ,
only_serials TEXT[] NOT NULL DEFAULT ARRAY[],
only_classes TEXT[] NOT NULL DEFAULT ARRAY[],

PRIMARY KEY (sitrep_id, request_id)
);
2 changes: 2 additions & 0 deletions schema/crdb/fm-support-bundle-request/up8.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE omicron.public.support_bundle
ADD COLUMN IF NOT EXISTS fm_case_id UUID;
Loading