Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjstone committed May 11, 2024
1 parent 1c6770b commit 10e27c5
Show file tree
Hide file tree
Showing 9 changed files with 847 additions and 787 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

26 changes: 23 additions & 3 deletions nexus/types/src/blueprint_diff.rs
Expand Up @@ -7,8 +7,8 @@
use crate::blueprint_display::{
constants::*, linear_table_modified, linear_table_unchanged, BpDiffState,
BpGeneration, BpOmicronZonesSubtableSchema, BpPhysicalDisksSubtableSchema,
BpSledSubtable, BpSledSubtableData, BpSledSubtableRow, BpSledTable,
KvListWithHeading, KvPair,
BpSledSubtable, BpSledSubtableData, BpSledSubtableRow, KvListWithHeading,
KvPair,
};
use crate::external_api::views::PhysicalDiskPolicy;
use omicron_common::api::external::Generation;
Expand Down Expand Up @@ -735,10 +735,13 @@ impl<'diff> fmt::Display for BlueprintDiffDisplay<'diff> {
// 2. Removed
// 3. Modified
// 4. Added
// 5. Errors
//
// The idea behind the order is to (a) group all changes together
// and (b) put changes towards the bottom, so people have to scroll
// back less.
//
// We put errors at the bottom to ensure they are seen immediately.

// Write out tables for unchanged sleds
if !diff.sleds_unchanged.is_empty() {
Expand Down Expand Up @@ -776,8 +779,25 @@ impl<'diff> fmt::Display for BlueprintDiffDisplay<'diff> {
}
}

// TODO: Show any errors
// Write out zone errors.
if !diff.zones.errors.is_empty() {
writeln!(f, "ERRORS:\n")?;
for (sled_id, errors) in &diff.zones.errors {
writeln!(f, "\n sled {sled_id}\n")?;
writeln!(
f,
" zone diff errors: before gen {}, after gen {}\n",
errors.generation_before, errors.generation_after
)?;

for err in &errors.errors {
writeln!(f, " zone id: {}", err.zone_before.id())?;
writeln!(f, " reason: {}", err.reason)?;
}
}
}

// Write out metadata diff table
writeln!(f, "{}", self.make_metadata_diff_table())?;

Ok(())
Expand Down
11 changes: 0 additions & 11 deletions nexus/types/src/blueprint_display.rs
Expand Up @@ -66,17 +66,6 @@ impl fmt::Display for BpDiffState {
}
}

/// A table representing an unmodified, modified, added, or removed sled
///
/// This table is meant for printing to the screen, and is generated from
/// [`Blueprint`]s or [`BlueprintDiff`]s. All subresources are contained under
/// this as their own [`BpSledSubtable`]s. `BpSledSubtable`s cannot be nested.
pub struct BpSledTable {
pub state: BpDiffState,
pub sled_id: SledUuid,
pub subtables: Vec<BpSledSubtable>,
}

/// A wrapper aound generation numbers for blueprints or blueprint diffs
#[derive(Debug, Clone, Copy)]
pub enum BpGeneration {
Expand Down
26 changes: 19 additions & 7 deletions nexus/types/src/deployment.rs
Expand Up @@ -1189,17 +1189,29 @@ impl BlueprintOrCollectionZoneConfig {
/// is invalid and we return an error message.
pub fn is_valid_modification(
&self,
other: &BlueprintZoneConfig,
after: &BlueprintZoneConfig,
) -> Result<(), String> {
let mut reason = String::new();
if self.kind() != other.kind() {
reason.push_str("mismatched zone kind; ");
if self.kind() != after.kind() {
let msg = format!(
"mismatched zone kind: before: {}, after: {}\n",
self.kind(),
after.kind()
);
reason.push_str(&msg);
}
if self.underlay_address() != other.underlay_address {
reason.push_str("mismatched underlay address; ");
if self.underlay_address() != after.underlay_address {
let msg = format!(
"mismatched underlay address: before: {}, after: {}\n",
self.underlay_address(),
after.underlay_address
);
reason.push_str(&msg);
}
if !self.is_zone_type_equal(&other.zone_type) {
reason.push_str("mismatched zone type; ");
if !self.is_zone_type_equal(&after.zone_type) {
let msg =
format!("mismatched zone type: after: {:?}\n", after.zone_type);
reason.push_str(&msg);
}

if reason.is_empty() {
Expand Down

0 comments on commit 10e27c5

Please sign in to comment.