Skip to content
Merged
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
23 changes: 23 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ members = [
"nexus/reconfigurator/execution",
"nexus/reconfigurator/planning",
"nexus/reconfigurator/preparation",
"nexus/reconfigurator/rendezvous",
"nexus/reconfigurator/simulation",
"nexus/saga-recovery",
"nexus/test-interface",
Expand Down Expand Up @@ -218,6 +219,7 @@ default-members = [
"nexus/reconfigurator/execution",
"nexus/reconfigurator/planning",
"nexus/reconfigurator/preparation",
"nexus/reconfigurator/rendezvous",
"nexus/reconfigurator/simulation",
"nexus/saga-recovery",
"nexus/test-interface",
Expand Down Expand Up @@ -479,6 +481,7 @@ nexus-reconfigurator-blippy = { path = "nexus/reconfigurator/blippy" }
nexus-reconfigurator-execution = { path = "nexus/reconfigurator/execution" }
nexus-reconfigurator-planning = { path = "nexus/reconfigurator/planning" }
nexus-reconfigurator-preparation = { path = "nexus/reconfigurator/preparation" }
nexus-reconfigurator-rendezvous = { path = "nexus/reconfigurator/rendezvous" }
nexus-reconfigurator-simulation = { path = "nexus/reconfigurator/simulation" }
nexus-saga-recovery = { path = "nexus/saga-recovery" }
nexus-sled-agent-shared = { path = "nexus-sled-agent-shared" }
Expand Down
2 changes: 2 additions & 0 deletions nexus/db-model/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ mod physical_disk_state;
mod probe;
mod producer_endpoint;
mod project;
mod rendezvous_debug_dataset;
mod semver_version;
mod switch_interface;
mod switch_port;
Expand Down Expand Up @@ -186,6 +187,7 @@ pub use region_replacement_step::*;
pub use region_snapshot::*;
pub use region_snapshot_replacement::*;
pub use region_snapshot_replacement_step::*;
pub use rendezvous_debug_dataset::*;
pub use role_assignment::*;
pub use role_builtin::*;
pub use saga_types::*;
Expand Down
79 changes: 79 additions & 0 deletions nexus/db-model/src/rendezvous_debug_dataset.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// 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/.

use crate::schema::rendezvous_debug_dataset;
use crate::typed_uuid::DbTypedUuid;
use chrono::{DateTime, Utc};
use omicron_uuid_kinds::BlueprintKind;
use omicron_uuid_kinds::BlueprintUuid;
use omicron_uuid_kinds::DatasetKind;
use omicron_uuid_kinds::DatasetUuid;
use omicron_uuid_kinds::ZpoolKind;
use omicron_uuid_kinds::ZpoolUuid;
use serde::{Deserialize, Serialize};

/// Database representation of a Debug Dataset available for use.
#[derive(
Queryable,
Insertable,
Debug,
Clone,
Selectable,
Deserialize,
Serialize,
PartialEq,
)]
#[diesel(table_name = rendezvous_debug_dataset)]
pub struct RendezvousDebugDataset {
id: DbTypedUuid<DatasetKind>,
time_created: DateTime<Utc>,
time_tombstoned: Option<DateTime<Utc>>,
pool_id: DbTypedUuid<ZpoolKind>,
blueprint_id_when_created: DbTypedUuid<BlueprintKind>,
blueprint_id_when_tombstoned: Option<DbTypedUuid<BlueprintKind>>,
}

impl RendezvousDebugDataset {
pub fn new(
id: DatasetUuid,
pool_id: ZpoolUuid,
blueprint_id: BlueprintUuid,
) -> Self {
Self {
id: id.into(),
time_created: Utc::now(),
time_tombstoned: None,
pool_id: pool_id.into(),
blueprint_id_when_created: blueprint_id.into(),
blueprint_id_when_tombstoned: None,
}
}

pub fn id(&self) -> DatasetUuid {
self.id.into()
}

pub fn pool_id(&self) -> ZpoolUuid {
self.pool_id.into()
}

pub fn blueprint_id_when_created(&self) -> BlueprintUuid {
self.blueprint_id_when_created.into()
}

pub fn blueprint_id_when_tombstoned(&self) -> Option<BlueprintUuid> {
self.blueprint_id_when_tombstoned.map(From::from)
}

pub fn is_tombstoned(&self) -> bool {
// A CHECK constraint in the schema guarantees both the `*_tombstoned`
// fields are set or not set; document that check here with an
// assertion.
debug_assert_eq!(
self.time_tombstoned.is_some(),
self.blueprint_id_when_tombstoned.is_some()
);
self.time_tombstoned.is_some()
}
}
11 changes: 11 additions & 0 deletions nexus/db-model/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,17 @@ table! {

allow_tables_to_appear_in_same_query!(zpool, dataset);

table! {
rendezvous_debug_dataset (id) {
id -> Uuid,
time_created -> Timestamptz,
time_tombstoned -> Nullable<Timestamptz>,
pool_id -> Uuid,
blueprint_id_when_created -> Uuid,
blueprint_id_when_tombstoned -> Nullable<Uuid>,
}
}

table! {
region (id) {
id -> Uuid,
Expand Down
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 @@ -17,7 +17,7 @@ use std::collections::BTreeMap;
///
/// 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: SemverVersion = SemverVersion::new(119, 0, 0);
pub const SCHEMA_VERSION: SemverVersion = SemverVersion::new(120, 0, 0);

/// List of all past database schema versions, in *reverse* order
///
Expand All @@ -29,6 +29,7 @@ static KNOWN_VERSIONS: Lazy<Vec<KnownVersion>> = Lazy::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(120, "rendezvous-debug-dataset"),
KnownVersion::new(119, "tuf-artifact-key-uuid"),
KnownVersion::new(118, "support-bundles"),
KnownVersion::new(117, "add-completing-and-new-region-volume"),
Expand Down
1 change: 1 addition & 0 deletions nexus/db-queries/src/db/datastore/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ mod region;
mod region_replacement;
mod region_snapshot;
pub mod region_snapshot_replacement;
mod rendezvous_debug_dataset;
mod role;
mod saga;
mod silo;
Expand Down
Loading