Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
edc851b
Add support for re-adopting physical disks
andrewjstone Apr 2, 2026
3ee2cc1
fix tests
andrewjstone Apr 7, 2026
260a348
expectorate
andrewjstone Apr 7, 2026
b4d48fe
minor fixes
andrewjstone Apr 9, 2026
2c79dd0
A few more review fixes
andrewjstone Apr 9, 2026
af22bb6
more small fixes
andrewjstone Apr 9, 2026
b246e49
Do not error bg task for not found
andrewjstone Apr 9, 2026
df9afa6
Fix my fix
andrewjstone Apr 9, 2026
1fe99e0
Try to fix some queries
andrewjstone Apr 9, 2026
b448340
fix unique constraint handling
andrewjstone Apr 9, 2026
daa5057
Use typed uuid
andrewjstone Apr 10, 2026
dcd1a06
add test and fix fn name
andrewjstone Apr 10, 2026
8bce6a0
Add delete endpoint and fix a bunch of stuff
andrewjstone Apr 10, 2026
87bc5a0
openapi
andrewjstone Apr 10, 2026
c9618fc
Auto adopt newly seen physical disks
andrewjstone Apr 20, 2026
e695804
Merge branch 'main' into manual-disk-adoption
andrewjstone Apr 20, 2026
a2ae344
fixes from review by sean
andrewjstone Apr 28, 2026
73c5c46
Make constructing a `PhysicalDisk` safer
andrewjstone Apr 28, 2026
85ef45c
Some fixes from johns review
andrewjstone Apr 28, 2026
f42bb35
more review fixes for john
andrewjstone Apr 28, 2026
bcce522
Merge branch 'main' into manual-disk-adoption
andrewjstone Apr 28, 2026
67235fa
Move to Helios v3
citrus-it Mar 13, 2026
9aa6473
Merge branch 'helios3' into manual-disk-adoption
andrewjstone May 6, 2026
698b3b8
Better handling of bg task status
andrewjstone May 6, 2026
5b8ab25
Merge branch 'main' into manual-disk-adoption
andrewjstone May 6, 2026
7ceb9a8
clippy
andrewjstone May 6, 2026
6a31229
fix schema version
andrewjstone May 7, 2026
ea0dcac
expectorate
andrewjstone May 7, 2026
522f7c9
openapi
andrewjstone May 8, 2026
875e4ce
huzzah
andrewjstone May 8, 2026
156f06e
NAMESPACE!!!!!!!!!!!!!
andrewjstone May 8, 2026
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 dev-tools/omdb/src/bin/omdb/nexus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ use nexus_types::internal_api::background::InstanceReincarnationStatus;
use nexus_types::internal_api::background::InstanceUpdaterStatus;
use nexus_types::internal_api::background::InventoryLoadStatus;
use nexus_types::internal_api::background::LookupRegionPortStatus;
use nexus_types::internal_api::background::PhysicalDiskAdoptionStatus;
use nexus_types::internal_api::background::ProbeDistributorStatus;
use nexus_types::internal_api::background::ReadOnlyRegionReplacementStartStatus;
use nexus_types::internal_api::background::RegionReplacementDriverStatus;
Expand Down Expand Up @@ -1300,6 +1301,9 @@ fn print_task_details(bgtask: &BackgroundTask, details: &serde_json::Value) {
"phantom_disks" => {
print_task_phantom_disks(details);
}
"physical_disk_adoption" => {
print_task_physical_disk_adoption(details);
}
"probe_distributor" => {
print_task_probe_distributor(details);
}
Expand Down Expand Up @@ -3949,6 +3953,25 @@ fn print_task_trust_quorum_manager(details: &serde_json::Value) {
}
}

fn print_task_physical_disk_adoption(details: &serde_json::Value) {
let status = match serde_json::from_value::<PhysicalDiskAdoptionStatus>(
details.clone(),
) {
Ok(status) => status,
Err(error) => {
eprintln!(
"warning: failed to interpret task details: {:?}: {:#?}",
error, details
);
return;
}
};
println!("physical disks added: {}", status.disks_added);
for error in status.errors {
println!("{ERRICON} {error}");
}
}

const ERRICON: &str = "/!\\";

fn warn_if_nonzero(n: usize) -> &'static str {
Expand Down
6 changes: 4 additions & 2 deletions dev-tools/omdb/tests/successes.out
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,8 @@ task: "physical_disk_adoption"
configured period: every <REDACTED_DURATION>s
last completed activation: <REDACTED ITERATIONS>, triggered by <TRIGGERED_BY_REDACTED>
started at <REDACTED_TIMESTAMP> (<REDACTED DURATION>s ago) and ran for <REDACTED DURATION>ms
last completion reported error: task disabled
physical disks added: 0
/!\ task disabled

task: "probe_distributor"
configured period: every <REDACTED_DURATION>m
Expand Down Expand Up @@ -1534,7 +1535,8 @@ task: "physical_disk_adoption"
configured period: every <REDACTED_DURATION>s
last completed activation: <REDACTED ITERATIONS>, triggered by <TRIGGERED_BY_REDACTED>
started at <REDACTED_TIMESTAMP> (<REDACTED DURATION>s ago) and ran for <REDACTED DURATION>ms
last completion reported error: task disabled
physical disks added: 0
/!\ task disabled

task: "probe_distributor"
configured period: every <REDACTED_DURATION>m
Expand Down
55 changes: 53 additions & 2 deletions nexus/db-model/src/physical_disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ use super::{
Generation, PhysicalDiskKind, PhysicalDiskPolicy, PhysicalDiskState,
};
use crate::DbTypedUuid;
use crate::InvPhysicalDisk;
use crate::collection::DatastoreCollectionConfig;
use chrono::{DateTime, Utc};
use db_macros::Asset;
use nexus_db_schema::schema::{physical_disk, zpool};
use nexus_types::external_api::physical_disk as physical_disk_types;
use nexus_types::external_api::physical_disk::PhysicalDiskManufacturerIdentity;
use nexus_types::identity::Asset;
use omicron_uuid_kinds::PhysicalDiskAdoptionRequestKind;
use omicron_uuid_kinds::PhysicalDiskKind as PhysicalDiskUuidKind;
use omicron_uuid_kinds::PhysicalDiskUuid;
use omicron_uuid_kinds::SledKind;
Expand All @@ -38,8 +41,20 @@ pub struct PhysicalDisk {
}

impl PhysicalDisk {
/// Creates a new in-service, active disk
pub fn new(
/// Creates a new in-service, active disk from an inventory disk
pub fn new(inv_disk: InvPhysicalDisk) -> Self {
Self::from_parts(
PhysicalDiskUuid::new_v4(),
inv_disk.vendor,
inv_disk.serial,
inv_disk.model,
inv_disk.variant,
inv_disk.sled_id.into(),
)
}

/// Creates a new in-service, active disk from individual fields
pub fn from_parts(
id: PhysicalDiskUuid,
vendor: String,
serial: String,
Expand Down Expand Up @@ -74,6 +89,14 @@ impl PhysicalDisk {
}
}

impl From<PhysicalDisk>
for physical_disk_types::PhysicalDiskManufacturerIdentity
{
fn from(value: PhysicalDisk) -> Self {
Self { vendor: value.vendor, serial: value.serial, model: value.model }
}
}

impl From<PhysicalDisk> for physical_disk_types::PhysicalDisk {
fn from(disk: PhysicalDisk) -> Self {
Self {
Expand All @@ -89,6 +112,34 @@ impl From<PhysicalDisk> for physical_disk_types::PhysicalDisk {
}
}

/// A request to adopt a physical disk into the control plane.
#[derive(Queryable, Insertable, Debug, Clone, Selectable)]
#[diesel(table_name = nexus_db_schema::schema::physical_disk_adoption_request)]
pub struct PhysicalDiskAdoptionRequest {
pub id: DbTypedUuid<PhysicalDiskAdoptionRequestKind>,
pub vendor: String,
pub serial: String,
pub model: String,
pub time_created: DateTime<Utc>,
pub time_deleted: Option<DateTime<Utc>>,
}

impl From<PhysicalDiskAdoptionRequest>
for physical_disk_types::PhysicalDiskAdoptionRequest
{
fn from(req: PhysicalDiskAdoptionRequest) -> Self {
Self {
id: req.id.into(),
disk_id: PhysicalDiskManufacturerIdentity {
vendor: req.vendor,
serial: req.serial,
model: req.model,
},
time_created: req.time_created,
}
}
}

impl DatastoreCollectionConfig<super::Zpool> for PhysicalDisk {
type CollectionId = DbTypedUuid<PhysicalDiskUuidKind>;
type GenerationNumberColumn = physical_disk::dsl::rcgen;
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 @@ -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(256, 0, 0);
pub const SCHEMA_VERSION: Version = Version::new(257, 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(257, "add-disk-adoption-requests"),
KnownVersion::new(256, "bgp-unnumbered-peer-cleanup"),
KnownVersion::new(255, "blueprint-add-external-networking-generation"),
KnownVersion::new(
Expand Down
2 changes: 1 addition & 1 deletion nexus/db-queries/src/db/datastore/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ mod test {
kind: PhysicalDiskKind,
serial: String,
) -> PhysicalDiskUuid {
let physical_disk = PhysicalDisk::new(
let physical_disk = PhysicalDisk::from_parts(
PhysicalDiskUuid::new_v4(),
TEST_VENDOR.into(),
serial,
Expand Down
Loading
Loading