Skip to content

Commit 393f64a

Browse files
committed
add disk generation to inventory
1 parent 1faf0b8 commit 393f64a

File tree

14 files changed

+39
-0
lines changed

14 files changed

+39
-0
lines changed

nexus-sled-agent-shared/src/inventory.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ pub struct Inventory {
103103
pub disks: Vec<InventoryDisk>,
104104
pub zpools: Vec<InventoryZpool>,
105105
pub datasets: Vec<InventoryDataset>,
106+
pub omicron_physical_disks_generation: Generation,
106107
}
107108

108109
/// Describes the role of the sled within the rack.

nexus/db-model/src/inventory.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,7 @@ pub struct InvSledAgent {
809809
pub usable_hardware_threads: SqlU32,
810810
pub usable_physical_ram: ByteCount,
811811
pub reservoir_size: ByteCount,
812+
pub omicron_physical_disks_generation: Generation,
812813
}
813814

814815
impl InvSledAgent {
@@ -852,6 +853,9 @@ impl InvSledAgent {
852853
sled_agent.usable_physical_ram,
853854
),
854855
reservoir_size: ByteCount::from(sled_agent.reservoir_size),
856+
omicron_physical_disks_generation: Generation::from(
857+
sled_agent.omicron_physical_disks_generation,
858+
),
855859
})
856860
}
857861
}

nexus/db-model/src/schema.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,7 @@ table! {
14861486
usable_hardware_threads -> Int8,
14871487
usable_physical_ram -> Int8,
14881488
reservoir_size -> Int8,
1489+
omicron_physical_disks_generation -> Int8,
14891490
}
14901491
}
14911492

nexus/db-queries/src/db/datastore/inventory.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,10 @@ impl DataStore {
889889
sled_agent.reservoir_size,
890890
)
891891
.into_sql::<diesel::sql_types::Int8>(),
892+
nexus_db_model::Generation(
893+
sled_agent.omicron_physical_disks_generation,
894+
)
895+
.into_sql::<diesel::sql_types::Int8>(),
892896
))
893897
.filter(
894898
baseboard_dsl::part_number
@@ -914,6 +918,7 @@ impl DataStore {
914918
sa_dsl::usable_hardware_threads,
915919
sa_dsl::usable_physical_ram,
916920
sa_dsl::reservoir_size,
921+
sa_dsl::omicron_physical_disks_generation,
917922
))
918923
.execute_async(&conn)
919924
.await?;
@@ -933,6 +938,7 @@ impl DataStore {
933938
_usable_hardware_threads,
934939
_usable_physical_ram,
935940
_reservoir_size,
941+
_omicron_physical_disks_generation,
936942
) = sa_dsl::inv_sled_agent::all_columns();
937943
}
938944

@@ -2377,6 +2383,9 @@ impl DataStore {
23772383
.get(sled_id.as_untyped_uuid())
23782384
.map(|datasets| datasets.to_vec())
23792385
.unwrap_or_default(),
2386+
omicron_physical_disks_generation: s
2387+
.omicron_physical_disks_generation
2388+
.into(),
23802389
};
23812390
sled_agents.insert(sled_id, sled_agent);
23822391
}

nexus/db-queries/src/db/datastore/physical_disk.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,8 @@ mod test {
702702
disks,
703703
zpools: vec![],
704704
datasets: vec![],
705+
omicron_physical_disks_generation:
706+
omicron_common::api::external::Generation::new(),
705707
},
706708
)
707709
.unwrap();

nexus/inventory/src/builder.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,8 @@ impl CollectionBuilder {
543543
.into_iter()
544544
.map(|d| d.into())
545545
.collect(),
546+
omicron_physical_disks_generation: inventory
547+
.omicron_physical_disks_generation,
546548
};
547549

548550
if let Some(previous) = self.sleds.get(&sled_id) {

nexus/inventory/src/examples.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,5 +573,6 @@ pub fn sled_agent(
573573
disks,
574574
zpools,
575575
datasets,
576+
omicron_physical_disks_generation: Generation::new(),
576577
}
577578
}

nexus/reconfigurator/planning/src/system.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,7 @@ impl Sled {
682682
})
683683
.collect(),
684684
datasets: vec![],
685+
omicron_physical_disks_generation: Generation::new(),
685686
}
686687
};
687688

@@ -820,6 +821,7 @@ impl Sled {
820821
disks: vec![],
821822
zpools: vec![],
822823
datasets: vec![],
824+
omicron_physical_disks_generation: Generation::new(),
823825
};
824826

825827
Sled {

nexus/types/src/inventory.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use nexus_sled_agent_shared::inventory::OmicronZoneConfig;
2525
use nexus_sled_agent_shared::inventory::OmicronZonesConfig;
2626
use nexus_sled_agent_shared::inventory::SledRole;
2727
use omicron_common::api::external::ByteCount;
28+
use omicron_common::api::external::Generation;
2829
pub use omicron_common::api::internal::shared::NetworkInterface;
2930
pub use omicron_common::api::internal::shared::NetworkInterfaceKind;
3031
pub use omicron_common::api::internal::shared::SourceNatConfig;
@@ -520,4 +521,13 @@ pub struct SledAgent {
520521
pub disks: Vec<PhysicalDisk>,
521522
pub zpools: Vec<Zpool>,
522523
pub datasets: Vec<Dataset>,
524+
/// As part of reconfigurator planning we need to know the control plane
525+
/// disks configuration that the sled-agent has seen last. Specifically,
526+
/// this allows the planner to know if a disk expungement has been seen by
527+
/// the sled-agent, so that the planner can decommission the expunged disk.
528+
///
529+
/// This field corresponds to the `generation` field in
530+
/// `OmicronPhysicalDisksConfig` that is stored in the blueprint and sent to
531+
/// the sled-agent via the executor over the internal API.
532+
pub omicron_physical_disks_generation: Generation,
523533
}

schema/crdb/dbinit.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3353,6 +3353,9 @@ CREATE TABLE IF NOT EXISTS omicron.public.inv_sled_agent (
33533353
usable_physical_ram INT8 NOT NULL,
33543354
reservoir_size INT8 CHECK (reservoir_size < usable_physical_ram) NOT NULL,
33553355

3356+
-- The last generation of OmicronPhysicalDisksConfig seen by the sled-agent
3357+
omicrion_physical_disks_generation INT8 NOT NULL,
3358+
33563359
PRIMARY KEY (inv_collection_id, sled_id)
33573360
);
33583361

0 commit comments

Comments
 (0)