Skip to content
Open
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
4 changes: 4 additions & 0 deletions dev-tools/omdb/src/bin/omdb/db/sitrep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ async fn cmd_db_sitrep_show(
comment,
next_inv_min_time_started,
alert_generation,
support_bundle_generation,
} = metadata;

const ID: &'static str = "ID";
Expand All @@ -264,6 +265,7 @@ async fn cmd_db_sitrep_show(
const NEXT_INV_MIN_START: &'static str =
" next inventory minimum start time";
const ALERT_GEN: &'static str = "alert generation";
const SUPPORT_BUNDLE_GEN: &'static str = "support bundle generation";
const TOTAL_EREPORTS: &'static str = "ereports in this sitrep";

const WIDTH: usize = const_max_len(&[
Expand All @@ -280,6 +282,7 @@ async fn cmd_db_sitrep_show(
INV_FINISHED_AT,
NEXT_INV_MIN_START,
ALERT_GEN,
SUPPORT_BUNDLE_GEN,
TOTAL_EREPORTS,
]);

Expand Down Expand Up @@ -355,6 +358,7 @@ async fn cmd_db_sitrep_show(
}
println!(" {NEXT_INV_MIN_START:>WIDTH$}: {next_inv_min_time_started}");
println!(" {ALERT_GEN:>WIDTH$}: {alert_generation}");
println!(" {SUPPORT_BUNDLE_GEN:>WIDTH$}: {support_bundle_generation}");
println!(" ");
println!(" {TOTAL_EREPORTS}: {}", ereports_by_id.len());
// TODO(eliza): perhaps display a table summarizing those ereports? possibly
Expand Down
13 changes: 8 additions & 5 deletions dev-tools/omdb/src/bin/omdb/nexus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3838,23 +3838,26 @@ fn print_task_fm_rendezvous(details: &serde_json::Value) {
total_bundles_requested,
current_sitrep_bundles_requested,
bundles_created,
bundles_already_existed,
stale_sitrep,
errors,
}| {
let already_created =
total_bundles_requested - bundles_created - errors.len();
const REQUESTED: &str = "support bundles requested:";
const REQUESTED_THIS_SITREP: &str = " requested in this sitrep:";
const CREATED: &str = " created in this activation:";
const ALREADY_CREATED: &str = " already created:";
const ALREADY_EXISTED: &str = " already existed:";
const ERRORS: &str = " errors:";
const WIDTH: usize = const_max_len(&[
REQUESTED,
REQUESTED_THIS_SITREP,
CREATED,
ALREADY_CREATED,
ALREADY_EXISTED,
ERRORS,
]) + 1;
pub const NUM_WIDTH: usize = 4;
if *stale_sitrep {
println!("{ERRICON} sitrep was stale");
}
println!(
" {REQUESTED:<WIDTH$}{total_bundles_requested:>NUM_WIDTH$}"
);
Expand All @@ -3864,7 +3867,7 @@ fn print_task_fm_rendezvous(details: &serde_json::Value) {
);
println!(" {CREATED:<WIDTH$}{bundles_created:>NUM_WIDTH$}");
println!(
" {ALREADY_CREATED:<WIDTH$}{already_created:>NUM_WIDTH$}"
" {ALREADY_EXISTED:<WIDTH$}{bundles_already_existed:>NUM_WIDTH$}"
);
println!(
"{} {ERRORS:<WIDTH$}{:>NUM_WIDTH$}",
Expand Down
4 changes: 2 additions & 2 deletions dev-tools/omdb/tests/successes.out
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ task: "fm_rendezvous"
support bundles requested: 0
requested in this sitrep: 0
created in this activation: 0
already created: 0
already existed: 0
errors: 0
marking ereports as seen:
(i) note: this operation was not executed
Expand Down Expand Up @@ -1428,7 +1428,7 @@ task: "fm_rendezvous"
support bundles requested: 0
requested in this sitrep: 0
created in this activation: 0
already created: 0
already existed: 0
errors: 0
marking ereports as seen:
(i) note: this operation was not executed
Expand Down
5 changes: 5 additions & 0 deletions nexus/db-model/src/fm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub struct SitrepMetadata {
pub comment: String,
pub next_inv_min_time_started: DateTime<Utc>,
pub alert_generation: Generation,
pub support_bundle_generation: Generation,
}

impl From<SitrepMetadata> for nexus_types::fm::SitrepMetadata {
Expand All @@ -56,6 +57,7 @@ impl From<SitrepMetadata> for nexus_types::fm::SitrepMetadata {
time_created,
next_inv_min_time_started,
alert_generation,
support_bundle_generation,
} = db_meta;
Self {
id: id.into(),
Expand All @@ -66,6 +68,7 @@ impl From<SitrepMetadata> for nexus_types::fm::SitrepMetadata {
comment,
time_created,
alert_generation: alert_generation.into(),
support_bundle_generation: support_bundle_generation.into(),
}
}
}
Expand All @@ -81,6 +84,7 @@ impl From<nexus_types::fm::SitrepMetadata> for SitrepMetadata {
time_created,
next_inv_min_time_started,
alert_generation,
support_bundle_generation,
} = db_meta;
Self {
id: id.into(),
Expand All @@ -91,6 +95,7 @@ impl From<nexus_types::fm::SitrepMetadata> for SitrepMetadata {
time_created,
next_inv_min_time_started,
alert_generation: alert_generation.into(),
support_bundle_generation: support_bundle_generation.into(),
}
}
}
Expand Down
32 changes: 29 additions & 3 deletions nexus/db-model/src/fm/rendezvous_created.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

//! Marker rows recording that FM rendezvous has successfully created an alert.
//! See the corresponding table comments in `schema/crdb/dbinit.sql` for the
//! tombstone-and-idempotency semantics that motivate these tables.
//! Marker rows recording that FM rendezvous has successfully created an alert
//! or support bundle. See the corresponding table comments in
//! `schema/crdb/dbinit.sql` for the tombstone-and-idempotency semantics that
//! motivate these tables.

use crate::Generation;
use crate::typed_uuid::DbTypedUuid;
use nexus_db_schema::schema::rendezvous_alert_created;
use nexus_db_schema::schema::rendezvous_support_bundle_created;
use omicron_uuid_kinds::{AlertKind, AlertUuid};
use omicron_uuid_kinds::{SupportBundleKind, SupportBundleUuid};

#[derive(Queryable, Insertable, Debug, Clone, Selectable, PartialEq)]
#[diesel(table_name = rendezvous_alert_created)]
Expand All @@ -27,3 +30,26 @@ impl RendezvousAlertCreated {
self.alert_id.into()
}
}

#[derive(Queryable, Insertable, Debug, Clone, Selectable, PartialEq)]
#[diesel(table_name = rendezvous_support_bundle_created)]
pub struct RendezvousSupportBundleCreated {
support_bundle_id: DbTypedUuid<SupportBundleKind>,
pub created_at_generation: Generation,
}

impl RendezvousSupportBundleCreated {
pub fn new(
support_bundle_id: SupportBundleUuid,
generation: Generation,
) -> Self {
Self {
support_bundle_id: support_bundle_id.into(),
created_at_generation: generation,
}
}

pub fn support_bundle_id(&self) -> SupportBundleUuid {
self.support_bundle_id.into()
}
}
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(264, 0, 0);
pub const SCHEMA_VERSION: Version = Version::new(265, 0, 0);

/// List of all past database schema versions, in *reverse* order
///
Expand All @@ -28,6 +28,7 @@ pub 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(265, "fm-bundle-resource-deletion"),
KnownVersion::new(264, "fm-alert-resource-deletion"),
KnownVersion::new(263, "external-jumbo-frames"),
KnownVersion::new(262, "rename-ip-pool-reservation-type"),
Expand Down
1 change: 1 addition & 0 deletions nexus/db-queries/src/db/datastore/alert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ mod tests {
parent_sitrep_id: None,
next_inv_min_time_started: Utc::now(),
alert_generation,
support_bundle_generation: Generation::new(),
},
cases: Default::default(),
ereports_by_id: Default::default(),
Expand Down
52 changes: 35 additions & 17 deletions nexus/db-queries/src/db/datastore/fm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,8 @@ mod tests {
time_created: Utc::now(),
parent_sitrep_id: None,
next_inv_min_time_started: Utc::now(),
alert_generation: Generation::from_u32(0),
alert_generation: Generation::new(),
support_bundle_generation: Generation::new(),
},
cases: Default::default(),
ereports_by_id: Default::default(),
Expand Down Expand Up @@ -1834,7 +1835,8 @@ mod tests {
time_created: Utc::now(),
parent_sitrep_id: None,
next_inv_min_time_started: Utc::now(),
alert_generation: Generation::from_u32(0),
alert_generation: Generation::new(),
support_bundle_generation: Generation::new(),
},
cases: Default::default(),
ereports_by_id: Default::default(),
Expand All @@ -1851,7 +1853,8 @@ mod tests {
time_created: Utc::now(),
parent_sitrep_id: Some(sitrep1.id()),
next_inv_min_time_started: Utc::now(),
alert_generation: Generation::from_u32(0),
alert_generation: Generation::new(),
support_bundle_generation: Generation::new(),
},
cases: Default::default(),
ereports_by_id: Default::default(),
Expand Down Expand Up @@ -1895,7 +1898,8 @@ mod tests {
time_created: Utc::now(),
parent_sitrep_id: None,
next_inv_min_time_started: Utc::now(),
alert_generation: Generation::from_u32(0),
alert_generation: Generation::new(),
support_bundle_generation: Generation::new(),
},
cases: Default::default(),
ereports_by_id: Default::default(),
Expand All @@ -1913,7 +1917,8 @@ mod tests {
time_created: Utc::now(),
parent_sitrep_id: Some(nonexistent_id),
next_inv_min_time_started: Utc::now(),
alert_generation: Generation::from_u32(0),
alert_generation: Generation::new(),
support_bundle_generation: Generation::new(),
},
cases: Default::default(),
ereports_by_id: Default::default(),
Expand Down Expand Up @@ -1951,7 +1956,8 @@ mod tests {
time_created: Utc::now(),
parent_sitrep_id: None,
next_inv_min_time_started: Utc::now(),
alert_generation: Generation::from_u32(0),
alert_generation: Generation::new(),
support_bundle_generation: Generation::new(),
},
cases: Default::default(),
ereports_by_id: Default::default(),
Expand All @@ -1968,7 +1974,8 @@ mod tests {
time_created: Utc::now(),
parent_sitrep_id: Some(sitrep1.id()),
next_inv_min_time_started: Utc::now(),
alert_generation: Generation::from_u32(0),
alert_generation: Generation::new(),
support_bundle_generation: Generation::new(),
},
cases: Default::default(),
ereports_by_id: Default::default(),
Expand All @@ -1986,7 +1993,8 @@ mod tests {
time_created: Utc::now(),
parent_sitrep_id: Some(sitrep1.id()),
next_inv_min_time_started: Utc::now(),
alert_generation: Generation::from_u32(0),
alert_generation: Generation::new(),
support_bundle_generation: Generation::new(),
},
cases: Default::default(),
ereports_by_id: Default::default(),
Expand Down Expand Up @@ -2318,7 +2326,8 @@ mod tests {
time_created: Utc::now(),
parent_sitrep_id: None,
next_inv_min_time_started: Utc::now(),
alert_generation: Generation::from_u32(0),
alert_generation: Generation::new(),
support_bundle_generation: Generation::new(),
},
cases,
ereports_by_id,
Expand Down Expand Up @@ -2429,7 +2438,8 @@ mod tests {
time_created: Utc::now(),
parent_sitrep_id: None,
next_inv_min_time_started: Utc::now(),
alert_generation: Generation::from_u32(0),
alert_generation: Generation::new(),
support_bundle_generation: Generation::new(),
},
cases,
ereports_by_id: Default::default(),
Expand Down Expand Up @@ -2482,7 +2492,8 @@ mod tests {
comment: "my cool sitrep".to_string(),
inv_collection_id: CollectionUuid::new_v4(),
next_inv_min_time_started: Utc::now(),
alert_generation: Generation::from_u32(0),
alert_generation: Generation::new(),
support_bundle_generation: Generation::new(),
},
cases: Default::default(),
ereports_by_id: Default::default(),
Expand Down Expand Up @@ -2640,7 +2651,8 @@ mod tests {
comment: "my cool sitrep".to_string(),
inv_collection_id: CollectionUuid::new_v4(),
next_inv_min_time_started: Utc::now(),
alert_generation: Generation::from_u32(0),
alert_generation: Generation::new(),
support_bundle_generation: Generation::new(),
},
cases: Default::default(),
ereports_by_id: Default::default(),
Expand Down Expand Up @@ -2775,7 +2787,8 @@ mod tests {
time_created: Utc::now(),
parent_sitrep_id: None,
next_inv_min_time_started: Utc::now(),
alert_generation: Generation::from_u32(0),
alert_generation: Generation::new(),
support_bundle_generation: Generation::new(),
},
cases: Default::default(),
ereports_by_id: Default::default(),
Expand Down Expand Up @@ -3013,7 +3026,8 @@ mod tests {
time_created: Utc::now(),
parent_sitrep_id: None,
next_inv_min_time_started: Utc::now(),
alert_generation: Generation::from_u32(0),
alert_generation: Generation::new(),
support_bundle_generation: Generation::new(),
},
cases: Default::default(),
ereports_by_id: Default::default(),
Expand Down Expand Up @@ -3141,7 +3155,8 @@ mod tests {
time_created: Utc::now(),
parent_sitrep_id: None,
next_inv_min_time_started: Utc::now(),
alert_generation: Generation::from_u32(0),
alert_generation: Generation::new(),
support_bundle_generation: Generation::new(),
},
cases: Default::default(),
ereports_by_id: Default::default(),
Expand Down Expand Up @@ -3437,7 +3452,8 @@ mod tests {
comment: "child sitrep".to_string(),
inv_collection_id: CollectionUuid::new_v4(),
next_inv_min_time_started: Utc::now(),
alert_generation: Generation::from_u32(0),
alert_generation: Generation::new(),
support_bundle_generation: Generation::new(),
},
cases: Default::default(),
ereports_by_id: Default::default(),
Expand Down Expand Up @@ -3748,18 +3764,20 @@ mod tests {
parent_sitrep_id: None,
next_inv_min_time_started: Utc::now(),
alert_generation: Generation::from_u32(5),
support_bundle_generation: Generation::from_u32(7),
},
cases: Default::default(),
ereports_by_id: Default::default(),
};

datastore.fm_sitrep_insert(&opctx, sitrep.clone()).await.unwrap();

// Read the persisted metadata back and assert the generation value
// Read the persisted metadata back and assert both generation values
// roundtripped correctly through the INSERT and SELECT.
let loaded =
datastore.fm_sitrep_metadata_read(&opctx, sitrep_id).await.unwrap();
assert_eq!(loaded.alert_generation, Generation::from_u32(5));
assert_eq!(loaded.support_bundle_generation, Generation::from_u32(7));

db.terminate().await;
logctx.cleanup_successful();
Expand Down
Loading
Loading