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

add pending MGS-managed updates to blueprint #7741

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 8 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions clients/gateway-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ workspace = true
[dependencies]
base64.workspace = true
chrono.workspace = true
daft.workspace = true
gateway-messages.workspace = true
progenitor.workspace = true
rand.workspace = true
Expand Down
1 change: 1 addition & 0 deletions clients/gateway-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ progenitor::generate_api!(
SpIgnition = { derives = [PartialEq, Eq, PartialOrd, Ord] },
SpIgnitionSystemType = { derives = [Copy, PartialEq, Eq, PartialOrd, Ord] },
SpState = { derives = [PartialEq, Eq, PartialOrd, Ord] },
SpType = { derives = [daft::Diffable] },
},
);

Expand Down
4 changes: 4 additions & 0 deletions common/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use std::{fmt, str::FromStr};

use daft::Diffable;
use hex::FromHexError;
use schemars::{
JsonSchema,
Expand Down Expand Up @@ -64,6 +65,7 @@ impl From<Artifact> for ArtifactId {
/// by name and version. This type indicates that.
#[derive(
Debug,
Diffable,
Clone,
PartialEq,
Eq,
Expand All @@ -86,6 +88,7 @@ pub struct ArtifactHashId {
#[derive(
Copy,
Clone,
Diffable,
Eq,
PartialEq,
Ord,
Expand All @@ -95,6 +98,7 @@ pub struct ArtifactHashId {
Deserialize,
JsonSchema,
)]
#[daft(leaf)]
#[serde(transparent)]
#[cfg_attr(feature = "testing", derive(test_strategy::Arbitrary))]
pub struct ArtifactHash(
Expand Down
2 changes: 2 additions & 0 deletions dev-tools/reconfigurator-cli/tests/output/cmd-example-stdout
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ parent: 02697f74-b14a-4418-90f0-c28b2a3a6aa9
internal DNS version: 1
external DNS version: 1

PENDING MGS-MANAGED UPDATES: 0


>
Expand Down Expand Up @@ -453,5 +454,6 @@ parent: 02697f74-b14a-4418-90f0-c28b2a3a6aa9
internal DNS version: 1
external DNS version: 1

PENDING MGS-MANAGED UPDATES: 0


Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ parent: 06c88262-f435-410e-ba98-101bed41ec27
internal DNS version: 1
external DNS version: 1

PENDING MGS-MANAGED UPDATES: 0


> blueprint-edit 3f00b694-1b16-4aaa-8f78-e6b3a527b434 expunge-zone 9995de32-dd52-4eb1-b0eb-141eb84bc739
Expand Down Expand Up @@ -605,6 +606,7 @@ parent: 3f00b694-1b16-4aaa-8f78-e6b3a527b434
internal DNS version: 1
external DNS version: 1

PENDING MGS-MANAGED UPDATES: 0


> blueprint-plan 366b0b68-d80e-4bc1-abd3-dc69837847e0
Expand Down Expand Up @@ -922,6 +924,7 @@ parent: 366b0b68-d80e-4bc1-abd3-dc69837847e0
internal DNS version: 1
external DNS version: 1

PENDING MGS-MANAGED UPDATES: 0


> blueprint-edit 9c998c1d-1a7b-440a-ae0c-40f781dea6e2 expunge-zone d786ef4a-5acb-4f5d-a732-a00addf986b5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ parent: 1b013011-2062-4b48-b544-a32b23bce83a
internal DNS version: 1
external DNS version: 1

PENDING MGS-MANAGED UPDATES: 0


>
Expand Down Expand Up @@ -192,6 +193,7 @@ parent: 971eeb12-1830-4fa0-a699-98ea0164505c
internal DNS version: 1
external DNS version: 1

PENDING MGS-MANAGED UPDATES: 0


> blueprint-diff 971eeb12-1830-4fa0-a699-98ea0164505c 9766ca20-38d4-4380-b005-e7c43c797e7c
Expand Down Expand Up @@ -455,6 +457,7 @@ parent: 9766ca20-38d4-4380-b005-e7c43c797e7c
internal DNS version: 1
external DNS version: 1

PENDING MGS-MANAGED UPDATES: 0


> blueprint-diff 9766ca20-38d4-4380-b005-e7c43c797e7c f714e6ea-e85a-4d7d-93c2-a018744fe176
Expand Down
2 changes: 2 additions & 0 deletions nexus/db-queries/src/db/datastore/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,8 @@ impl DataStore {

Ok(Blueprint {
id: blueprint_id,
// TODO these need to be serialized to the database.
pending_mgs_updates: BTreeMap::new(),
sleds: sled_configs,
parent_blueprint_id,
internal_dns_version,
Expand Down
5 changes: 5 additions & 0 deletions nexus/db-queries/src/db/datastore/rack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,7 @@ mod test {
blueprint: Blueprint {
id: BlueprintUuid::new_v4(),
sleds: BTreeMap::new(),
pending_mgs_updates: BTreeMap::new(),
cockroachdb_setting_preserve_downgrade:
CockroachDbPreserveDowngrade::DoNotModify,
parent_blueprint_id: None,
Expand Down Expand Up @@ -1539,6 +1540,7 @@ mod test {
let blueprint = Blueprint {
id: BlueprintUuid::new_v4(),
sleds: make_sled_config_only_zones(blueprint_zones),
pending_mgs_updates: BTreeMap::new(),
cockroachdb_setting_preserve_downgrade:
CockroachDbPreserveDowngrade::DoNotModify,
parent_blueprint_id: None,
Expand Down Expand Up @@ -1796,6 +1798,7 @@ mod test {
let blueprint = Blueprint {
id: BlueprintUuid::new_v4(),
sleds: make_sled_config_only_zones(blueprint_zones),
pending_mgs_updates: BTreeMap::new(),
cockroachdb_setting_preserve_downgrade:
CockroachDbPreserveDowngrade::DoNotModify,
parent_blueprint_id: None,
Expand Down Expand Up @@ -2002,6 +2005,7 @@ mod test {
let blueprint = Blueprint {
id: BlueprintUuid::new_v4(),
sleds: make_sled_config_only_zones(blueprint_zones),
pending_mgs_updates: BTreeMap::new(),
cockroachdb_setting_preserve_downgrade:
CockroachDbPreserveDowngrade::DoNotModify,
parent_blueprint_id: None,
Expand Down Expand Up @@ -2138,6 +2142,7 @@ mod test {
let blueprint = Blueprint {
id: BlueprintUuid::new_v4(),
sleds: make_sled_config_only_zones(blueprint_zones),
pending_mgs_updates: BTreeMap::new(),
cockroachdb_setting_preserve_downgrade:
CockroachDbPreserveDowngrade::DoNotModify,
parent_blueprint_id: None,
Expand Down
1 change: 1 addition & 0 deletions nexus/reconfigurator/execution/src/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ mod test {
let mut blueprint = Blueprint {
id: BlueprintUuid::new_v4(),
sleds: blueprint_sleds,
pending_mgs_updates: BTreeMap::new(),
cockroachdb_setting_preserve_downgrade:
CockroachDbPreserveDowngrade::DoNotModify,
parent_blueprint_id: None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ impl<'a> BlueprintBuilder<'a> {
Blueprint {
id: rng.next_blueprint(),
sleds,
pending_mgs_updates: BTreeMap::new(),
parent_blueprint_id: None,
internal_dns_version: Generation::new(),
external_dns_version: Generation::new(),
Expand Down Expand Up @@ -710,6 +711,10 @@ impl<'a> BlueprintBuilder<'a> {
Blueprint {
id: blueprint_id,
sleds,
pending_mgs_updates: self
.parent_blueprint
.pending_mgs_updates
.clone(),
parent_blueprint_id: Some(self.parent_blueprint.id),
internal_dns_version: self.input.internal_dns_version(),
external_dns_version: self.input.external_dns_version(),
Expand Down
1 change: 1 addition & 0 deletions nexus/src/app/background/tasks/blueprint_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ mod test {
let blueprint = Blueprint {
id,
sleds: blueprint_sleds,
pending_mgs_updates: BTreeMap::new(),
cockroachdb_setting_preserve_downgrade:
CockroachDbPreserveDowngrade::DoNotModify,
parent_blueprint_id: Some(current_target.target_id),
Expand Down
1 change: 1 addition & 0 deletions nexus/src/app/background/tasks/blueprint_load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ mod test {
Blueprint {
id,
sleds: BTreeMap::new(),
pending_mgs_updates: BTreeMap::new(),
cockroachdb_setting_preserve_downgrade:
CockroachDbPreserveDowngrade::DoNotModify,
parent_blueprint_id: Some(parent_blueprint_id),
Expand Down
1 change: 1 addition & 0 deletions nexus/test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,7 @@ impl<'a, N: NexusServer> ControlPlaneTestContextBuilder<'a, N> {
Blueprint {
id: BlueprintUuid::new_v4(),
sleds: blueprint_sleds,
pending_mgs_updates: BTreeMap::new(),
parent_blueprint_id: None,
internal_dns_version: dns_config.generation,
external_dns_version: Generation::new(),
Expand Down
55 changes: 55 additions & 0 deletions nexus/types/src/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ use blueprint_display::{
};
use id_map::{IdMap, IdMappable};

use crate::inventory::BaseboardId;
pub use blueprint_diff::BlueprintDiffSummary;
use blueprint_display::BpPendingMgsUpdates;
use gateway_client::types::SpType;
use omicron_common::update::ArtifactHashId;

/// Describes a complete set of software and configuration for the system
// Blueprints are a fundamental part of how the system modifies itself. Each
Expand Down Expand Up @@ -151,6 +155,9 @@ pub struct Blueprint {
/// A map of sled id -> desired configuration of the sled.
pub sleds: BTreeMap<SledUuid, BlueprintSledConfig>,

/// List of pending MGS-mediated updates
pub pending_mgs_updates: BTreeMap<BaseboardId, PendingMgsUpdate>,

/// which blueprint this blueprint is based on
pub parent_blueprint_id: Option<BlueprintUuid>,

Expand Down Expand Up @@ -488,6 +495,7 @@ impl fmt::Display for BlueprintDisplay<'_> {
let Blueprint {
id,
sleds,
pending_mgs_updates,
parent_blueprint_id,
// These two cockroachdb_* fields are handled by
// `make_cockroachdb_table()`, called below.
Expand Down Expand Up @@ -569,6 +577,38 @@ impl fmt::Display for BlueprintDisplay<'_> {
writeln!(f, "{}", self.make_cockroachdb_table())?;
writeln!(f, "{}", self.make_metadata_table())?;

writeln!(
f,
" PENDING MGS-MANAGED UPDATES: {}",
pending_mgs_updates.len()
)?;
if !pending_mgs_updates.is_empty() {
writeln!(
f,
"{}",
BpTable::new(
BpPendingMgsUpdates {},
None,
pending_mgs_updates
.values()
.map(|pu| {
BpTableRow::from_strings(
BpDiffState::Unchanged,
vec![
pu.sp_type.to_string(),
pu.slot_id.to_string(),
pu.baseboard_id.part_number.clone(),
pu.baseboard_id.serial_number.clone(),
pu.artifact_hash_id.kind.to_string(),
pu.artifact_hash_id.hash.to_string(),
],
)
})
.collect()
)
)?;
}

Ok(())
}
}
Expand Down Expand Up @@ -963,6 +1003,21 @@ impl fmt::Display for BlueprintZoneImageSource {
}
}

#[derive(
Clone, Debug, Eq, PartialEq, JsonSchema, Deserialize, Serialize, Diffable,
)]
pub struct PendingMgsUpdate {
/// id of the baseboard that we're going to update
baseboard_id: BaseboardId,
/// what type of baseboard this is
sp_type: SpType,
/// last known MGS slot (cubby number) of the baseboard
slot_id: u16,
/// which artifact to apply to this device
/// (implies which component is being updated)
artifact_hash_id: ArtifactHashId,
}

/// The desired state of an Omicron-managed physical disk in a blueprint.
#[derive(
Debug,
Expand Down
3 changes: 3 additions & 0 deletions nexus/types/src/deployment/blueprint_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ impl<'a> BlueprintDiffSummary<'a> {
let BlueprintDiff {
// Fields in which changes are meaningful.
sleds,
// TODO Will need to diff these when we can actually create
// blueprints with pending MGS updates.
pending_mgs_updates: _,
clickhouse_cluster_config,
// Metadata fields for which changes don't reflect semantic
// changes from one blueprint to the next.
Expand Down
Loading
Loading