Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[reconfigurator] Add rendezvous_debug_dataset table #7341

Merged
merged 5 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -475,6 +477,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
66 changes: 66 additions & 0 deletions nexus/db-model/src/rendezvous_debug_dataset.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// 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_recorded: 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_recorded: blueprint_id.into(),
}
}

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

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

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

pub fn is_tombstoned(&self) -> bool {
self.time_tombstoned.is_some()
}
}
10 changes: 10 additions & 0 deletions nexus/db-model/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,16 @@ 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_recorded -> 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(118, 0, 0);
pub const SCHEMA_VERSION: SemverVersion = SemverVersion::new(119, 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(119, "rendezvous-debug-dataset"),
KnownVersion::new(118, "support-bundles"),
KnownVersion::new(117, "add-completing-and-new-region-volume"),
KnownVersion::new(116, "bp-physical-disk-disposition"),
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
Loading