Skip to content

Commit 85446aa

Browse files
committed
Add nexus_generation to blueprint
1 parent a9d9f1e commit 85446aa

File tree

32 files changed

+958
-24
lines changed

32 files changed

+958
-24
lines changed

nexus/db-model/src/deployment.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ pub struct Blueprint {
8181
pub creator: String,
8282
pub comment: String,
8383
pub target_release_minimum_generation: Generation,
84+
pub nexus_generation: Generation,
8485
}
8586

8687
impl From<&'_ nexus_types::deployment::Blueprint> for Blueprint {
@@ -100,6 +101,7 @@ impl From<&'_ nexus_types::deployment::Blueprint> for Blueprint {
100101
target_release_minimum_generation: Generation(
101102
bp.target_release_minimum_generation,
102103
),
104+
nexus_generation: Generation(bp.nexus_generation),
103105
}
104106
}
105107
}
@@ -113,6 +115,7 @@ impl From<Blueprint> for nexus_types::deployment::BlueprintMetadata {
113115
external_dns_version: *value.external_dns_version,
114116
target_release_minimum_generation: *value
115117
.target_release_minimum_generation,
118+
nexus_generation: *value.nexus_generation,
116119
cockroachdb_fingerprint: value.cockroachdb_fingerprint,
117120
cockroachdb_setting_preserve_downgrade:
118121
CockroachDbPreserveDowngrade::from_optional_string(
@@ -524,6 +527,7 @@ pub struct BpOmicronZone {
524527

525528
pub image_source: DbBpZoneImageSource,
526529
pub image_artifact_sha256: Option<ArtifactHash>,
530+
pub nexus_generation: Option<Generation>,
527531
}
528532

529533
impl BpOmicronZone {
@@ -585,6 +589,7 @@ impl BpOmicronZone {
585589
snat_ip: None,
586590
snat_first_port: None,
587591
snat_last_port: None,
592+
nexus_generation: None,
588593
};
589594

590595
match &blueprint_zone.zone_type {
@@ -716,6 +721,7 @@ impl BpOmicronZone {
716721
nic,
717722
external_tls,
718723
external_dns_servers,
724+
nexus_generation,
719725
}) => {
720726
// Set the common fields
721727
bp_omicron_zone
@@ -733,6 +739,8 @@ impl BpOmicronZone {
733739
.map(IpNetwork::from)
734740
.collect(),
735741
);
742+
bp_omicron_zone.nexus_generation =
743+
Some(Generation::from(*nexus_generation));
736744
}
737745
BlueprintZoneType::Oximeter(blueprint_zone_type::Oximeter {
738746
address,
@@ -938,6 +946,9 @@ impl BpOmicronZone {
938946
.into_iter()
939947
.map(|i| i.ip())
940948
.collect(),
949+
nexus_generation: *self.nexus_generation.ok_or_else(
950+
|| anyhow!("expected 'nexus_generation'"),
951+
)?,
941952
})
942953
}
943954
ZoneType::Oximeter => {

nexus/db-model/src/schema_versions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::{collections::BTreeMap, sync::LazyLock};
1616
///
1717
/// This must be updated when you change the database schema. Refer to
1818
/// schema/crdb/README.adoc in the root of this repository for details.
19-
pub const SCHEMA_VERSION: Version = Version::new(181, 0, 0);
19+
pub const SCHEMA_VERSION: Version = Version::new(182, 0, 0);
2020

2121
/// List of all past database schema versions, in *reverse* order
2222
///
@@ -28,6 +28,7 @@ static KNOWN_VERSIONS: LazyLock<Vec<KnownVersion>> = LazyLock::new(|| {
2828
// | leaving the first copy as an example for the next person.
2929
// v
3030
// KnownVersion::new(next_int, "unique-dirname-with-the-sql-files"),
31+
KnownVersion::new(182, "nexus-generation"),
3132
KnownVersion::new(181, "rename-nat-table"),
3233
KnownVersion::new(180, "sled-cpu-family"),
3334
KnownVersion::new(179, "add-pending-mgs-updates-host-phase-1"),

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ impl DataStore {
548548
internal_dns_version,
549549
external_dns_version,
550550
target_release_minimum_generation,
551+
nexus_generation,
551552
cockroachdb_fingerprint,
552553
cockroachdb_setting_preserve_downgrade,
553554
time_created,
@@ -574,6 +575,7 @@ impl DataStore {
574575
*blueprint.internal_dns_version,
575576
*blueprint.external_dns_version,
576577
*blueprint.target_release_minimum_generation,
578+
*blueprint.nexus_generation,
577579
blueprint.cockroachdb_fingerprint,
578580
blueprint.cockroachdb_setting_preserve_downgrade,
579581
blueprint.time_created,
@@ -1325,6 +1327,7 @@ impl DataStore {
13251327
internal_dns_version,
13261328
external_dns_version,
13271329
target_release_minimum_generation,
1330+
nexus_generation,
13281331
cockroachdb_fingerprint,
13291332
cockroachdb_setting_preserve_downgrade,
13301333
clickhouse_cluster_config,
@@ -4263,6 +4266,7 @@ mod tests {
42634266
},
42644267
external_tls: false,
42654268
external_dns_servers: vec![],
4269+
nexus_generation: Generation::new(),
42664270
},
42674271
),
42684272
image_source: BlueprintZoneImageSource::InstallDataset,

nexus/db-queries/src/db/datastore/deployment/external_networking.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ mod tests {
433433
use omicron_common::address::NEXUS_OPTE_IPV4_SUBNET;
434434
use omicron_common::address::NTP_OPTE_IPV4_SUBNET;
435435
use omicron_common::address::NUM_SOURCE_NAT_PORTS;
436+
use omicron_common::api::external::Generation;
436437
use omicron_common::api::external::MacAddr;
437438
use omicron_common::api::external::Vni;
438439
use omicron_common::zpool_name::ZpoolName;
@@ -617,6 +618,7 @@ mod tests {
617618
nic: self.nexus_nic.clone(),
618619
external_tls: false,
619620
external_dns_servers: Vec::new(),
621+
nexus_generation: Generation::new(),
620622
},
621623
),
622624
image_source: BlueprintZoneImageSource::InstallDataset,

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,7 @@ mod test {
10641064
internal_dns_version: *Generation::new(),
10651065
external_dns_version: *Generation::new(),
10661066
target_release_minimum_generation: *Generation::new(),
1067+
nexus_generation: *Generation::new(),
10671068
cockroachdb_fingerprint: String::new(),
10681069
clickhouse_cluster_config: None,
10691070
oximeter_read_version: *Generation::new(),
@@ -1488,6 +1489,7 @@ mod test {
14881489
slot: 0,
14891490
transit_ips: vec![],
14901491
},
1492+
nexus_generation: *Generation::new(),
14911493
},
14921494
),
14931495
image_source: BlueprintZoneImageSource::InstallDataset,
@@ -1558,6 +1560,7 @@ mod test {
15581560
internal_dns_version: *Generation::new(),
15591561
external_dns_version: *Generation::new(),
15601562
target_release_minimum_generation: *Generation::new(),
1563+
nexus_generation: *Generation::new(),
15611564
cockroachdb_fingerprint: String::new(),
15621565
clickhouse_cluster_config: None,
15631566
oximeter_read_version: *Generation::new(),
@@ -1744,6 +1747,7 @@ mod test {
17441747
slot: 0,
17451748
transit_ips: vec![],
17461749
},
1750+
nexus_generation: *Generation::new(),
17471751
},
17481752
),
17491753
image_source: BlueprintZoneImageSource::InstallDataset,
@@ -1777,6 +1781,7 @@ mod test {
17771781
slot: 0,
17781782
transit_ips: vec![],
17791783
},
1784+
nexus_generation: *Generation::new(),
17801785
},
17811786
),
17821787
image_source: BlueprintZoneImageSource::InstallDataset,
@@ -1821,6 +1826,7 @@ mod test {
18211826
internal_dns_version: *Generation::new(),
18221827
external_dns_version: *Generation::new(),
18231828
target_release_minimum_generation: *Generation::new(),
1829+
nexus_generation: *Generation::new(),
18241830
cockroachdb_fingerprint: String::new(),
18251831
clickhouse_cluster_config: None,
18261832
oximeter_read_version: *Generation::new(),
@@ -2015,6 +2021,7 @@ mod test {
20152021
slot: 0,
20162022
transit_ips: vec![],
20172023
},
2024+
nexus_generation: *Generation::new(),
20182025
},
20192026
),
20202027
image_source: BlueprintZoneImageSource::InstallDataset,
@@ -2033,6 +2040,7 @@ mod test {
20332040
internal_dns_version: *Generation::new(),
20342041
external_dns_version: *Generation::new(),
20352042
target_release_minimum_generation: *Generation::new(),
2043+
nexus_generation: *Generation::new(),
20362044
cockroachdb_fingerprint: String::new(),
20372045
clickhouse_cluster_config: None,
20382046
oximeter_read_version: *Generation::new(),
@@ -2155,6 +2163,7 @@ mod test {
21552163
slot: 0,
21562164
transit_ips: vec![],
21572165
},
2166+
nexus_generation: *Generation::new(),
21582167
},
21592168
),
21602169
image_source: BlueprintZoneImageSource::InstallDataset,
@@ -2175,6 +2184,7 @@ mod test {
21752184
internal_dns_version: *Generation::new(),
21762185
external_dns_version: *Generation::new(),
21772186
target_release_minimum_generation: *Generation::new(),
2187+
nexus_generation: *Generation::new(),
21782188
cockroachdb_fingerprint: String::new(),
21792189
clickhouse_cluster_config: None,
21802190
oximeter_read_version: *Generation::new(),

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3330,12 +3330,12 @@ mod tests {
33303330
)
33313331
.expect("ensured disks");
33323332
}
3333+
let must_have_nexus_zones = false;
33333334
builder
3334-
.sled_add_zone_nexus_with_config(
3335+
.sled_add_zone_nexus_internal(
33353336
sled_ids[2],
3336-
false,
3337-
Vec::new(),
33383337
BlueprintZoneImageSource::InstallDataset,
3338+
must_have_nexus_zones,
33393339
)
33403340
.expect("added nexus to third sled");
33413341
builder.build()
@@ -3405,12 +3405,12 @@ mod tests {
34053405
)
34063406
.expect("created blueprint builder");
34073407
for &sled_id in &sled_ids {
3408+
let must_have_nexus_zones = false;
34083409
builder
3409-
.sled_add_zone_nexus_with_config(
3410+
.sled_add_zone_nexus_internal(
34103411
sled_id,
3411-
false,
3412-
Vec::new(),
34133412
BlueprintZoneImageSource::InstallDataset,
3413+
must_have_nexus_zones,
34143414
)
34153415
.expect("added nexus to third sled");
34163416
}

nexus/db-schema/src/schema.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,6 +1966,8 @@ table! {
19661966
cockroachdb_setting_preserve_downgrade -> Nullable<Text>,
19671967

19681968
target_release_minimum_generation -> Int8,
1969+
1970+
nexus_generation -> Int8,
19691971
}
19701972
}
19711973

@@ -2066,6 +2068,7 @@ table! {
20662068
filesystem_pool -> Uuid,
20672069
image_source -> crate::enums::BpZoneImageSourceEnum,
20682070
image_artifact_sha256 -> Nullable<Text>,
2071+
nexus_generation -> Nullable<Int8>,
20692072
}
20702073
}
20712074

nexus/reconfigurator/blippy/src/blippy.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use nexus_types::inventory::ZpoolName;
1414
use omicron_common::address::DnsSubnet;
1515
use omicron_common::address::Ipv6Subnet;
1616
use omicron_common::address::SLED_PREFIX;
17+
use omicron_common::api::external::Generation;
1718
use omicron_common::api::external::MacAddr;
1819
use omicron_common::disk::DatasetKind;
1920
use omicron_common::disk::M2Slot;
@@ -193,6 +194,12 @@ pub enum SledKind {
193194
version: BlueprintArtifactVersion,
194195
hash: ArtifactHash,
195196
},
197+
/// Nexus zones with the same generation have different image sources.
198+
NexusZoneGenerationImageSourceMismatch {
199+
zone1: BlueprintZoneConfig,
200+
zone2: BlueprintZoneConfig,
201+
generation: Generation,
202+
},
196203
}
197204

198205
impl fmt::Display for SledKind {
@@ -415,6 +422,18 @@ impl fmt::Display for SledKind {
415422
(version {version}, hash {hash})",
416423
)
417424
}
425+
SledKind::NexusZoneGenerationImageSourceMismatch {
426+
zone1,
427+
zone2,
428+
generation,
429+
} => {
430+
write!(
431+
f,
432+
"Nexus zones {} and {} both have generation {generation} but \
433+
different image sources ({:?} vs {:?})",
434+
zone1.id, zone2.id, zone1.image_source, zone2.image_source,
435+
)
436+
}
418437
}
419438
}
420439
}

0 commit comments

Comments
 (0)