Skip to content

Commit

Permalink
log summary of sled changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jgallagher committed Dec 4, 2024
1 parent e65a79e commit e807ea9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
30 changes: 27 additions & 3 deletions nexus/reconfigurator/planning/src/blueprint_builder/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ pub struct SledEditCounts {
}

impl SledEditCounts {
fn has_nonzero_counts(&self) -> bool {
let Self { disks, datasets, zones } = self;
disks.has_nonzero_counts()
|| datasets.has_nonzero_counts()
|| zones.has_nonzero_counts()
}

fn difference_since(self, other: Self) -> Self {
Self {
disks: self.disks.difference_since(other.disks),
Expand Down Expand Up @@ -613,20 +620,37 @@ impl<'a> BlueprintBuilder<'a> {

/// Assemble a final [`Blueprint`] based on the contents of the builder
pub fn build(mut self) -> Blueprint {
let blueprint_id = self.rng.next_blueprint();

// Collect the Omicron zones config for all sleds, including sleds that
// are no longer in service and need expungement work.
let mut sled_state = BTreeMap::new();
let mut blueprint_zones = BTreeMap::new();
let mut blueprint_disks = BTreeMap::new();
let mut blueprint_datasets = BTreeMap::new();
for (sled_id, editor) in self.sled_editors {
// TODO-john use all fields
let EditedSled { zones, disks, datasets, state, .. } =
let EditedSled { zones, disks, datasets, state, edit_counts } =
editor.finalize();
sled_state.insert(sled_id, state);
blueprint_disks.insert(sled_id, disks);
blueprint_datasets.insert(sled_id, datasets);
blueprint_zones.insert(sled_id, zones);
if edit_counts.has_nonzero_counts() {
info!(
self.log, "sled modified in new blueprint";
"sled_id" => %sled_id,
"blueprint_id" => %blueprint_id,
"disk_edits" => ?edit_counts.disks,
"dataset_edits" => ?edit_counts.datasets,
"zone_edits" => ?edit_counts.zones,
);
} else {
info!(
self.log, "sled unchanged in new blueprint";
"sled_id" => %sled_id,
"blueprint_id" => %blueprint_id,
);
}
}
// Preserving backwards compatibility, for now: prune sled_state of any
// fully decommissioned sleds, which we determine by the state being
Expand Down Expand Up @@ -717,7 +741,7 @@ impl<'a> BlueprintBuilder<'a> {
}
});
Blueprint {
id: self.rng.next_blueprint(),
id: blueprint_id,
blueprint_zones,
blueprint_disks,
blueprint_datasets,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use crate::planner::PlannerRng;
use illumos_utils::zpool::ZpoolName;
use nexus_types::deployment::blueprint_zone_type;
use nexus_types::deployment::BlueprintDatasetConfig;
use nexus_types::deployment::BlueprintDatasetFilter;
use nexus_types::deployment::BlueprintDatasetsConfig;
use nexus_types::deployment::BlueprintPhysicalDiskConfig;
use nexus_types::deployment::BlueprintPhysicalDisksConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::planner::PlannerRng;
use illumos_utils::zpool::ZpoolName;
use nexus_types::deployment::BlueprintDatasetConfig;
use nexus_types::deployment::BlueprintDatasetDisposition;
use nexus_types::deployment::BlueprintDatasetFilter;
use nexus_types::deployment::BlueprintDatasetsConfig;
use omicron_common::api::external::ByteCount;
use omicron_common::api::external::Generation;
Expand Down

0 comments on commit e807ea9

Please sign in to comment.