Skip to content

Commit 7839573

Browse files
committed
Send blueprint disks & datasets to simulated sled agent
1 parent caa1d50 commit 7839573

File tree

2 files changed

+40
-53
lines changed

2 files changed

+40
-53
lines changed

dev-tools/omdb/tests/successes.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,7 @@ stdout:
14091409
blueprint ......<REDACTED_BLUEPRINT_ID>.......
14101410
parent: <none>
14111411

1412-
sled: ..........<REDACTED_UUID>........... (active, config generation 2)
1412+
sled: ..........<REDACTED_UUID>........... (active, config generation 4)
14131413

14141414
physical disks:
14151415
-----------------------------------------------------------------
@@ -1440,7 +1440,7 @@ parent: <none>
14401440

14411441

14421442

1443-
sled: ..........<REDACTED_UUID>........... (active, config generation 2)
1443+
sled: ..........<REDACTED_UUID>........... (active, config generation 4)
14441444

14451445
physical disks:
14461446
----------------------------------------------------------------
@@ -1513,7 +1513,7 @@ stdout:
15131513
blueprint ......<REDACTED_BLUEPRINT_ID>.......
15141514
parent: <none>
15151515

1516-
sled: ..........<REDACTED_UUID>........... (active, config generation 2)
1516+
sled: ..........<REDACTED_UUID>........... (active, config generation 4)
15171517

15181518
physical disks:
15191519
-----------------------------------------------------------------
@@ -1544,7 +1544,7 @@ parent: <none>
15441544

15451545

15461546

1547-
sled: ..........<REDACTED_UUID>........... (active, config generation 2)
1547+
sled: ..........<REDACTED_UUID>........... (active, config generation 4)
15481548

15491549
physical disks:
15501550
----------------------------------------------------------------

nexus/test-utils/src/lib.rs

Lines changed: 36 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ use slog::{Logger, debug, error, o};
9595
use std::collections::BTreeMap;
9696
use std::collections::HashMap;
9797
use std::fmt::Debug;
98+
use std::iter::{once, repeat, zip};
9899
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV6};
99100
use std::sync::Arc;
100101
use std::time::Duration;
@@ -394,6 +395,8 @@ pub struct ControlPlaneTestContextBuilder<'a, N: NexusServer> {
394395
pub internal_dns: Option<dns_server::TransientServer>,
395396
dns_config: Option<DnsConfigParams>,
396397
initial_blueprint_id: Option<BlueprintUuid>,
398+
blueprint_disks: BTreeMap<SledUuid, IdMap<BlueprintPhysicalDiskConfig>>,
399+
blueprint_datasets: BTreeMap<SledUuid, IdMap<BlueprintDatasetConfig>>,
397400
blueprint_zones: Vec<BlueprintZoneConfig>,
398401

399402
pub silo_name: Option<Name>,
@@ -442,6 +445,8 @@ impl<'a, N: NexusServer> ControlPlaneTestContextBuilder<'a, N> {
442445
internal_dns: None,
443446
dns_config: None,
444447
initial_blueprint_id: None,
448+
blueprint_disks: BTreeMap::new(),
449+
blueprint_datasets: BTreeMap::new(),
445450
blueprint_zones: Vec::new(),
446451
silo_name: None,
447452
user_name: None,
@@ -843,7 +848,7 @@ impl<'a, N: NexusServer> ControlPlaneTestContextBuilder<'a, N> {
843848
self.dns_config = Some(dns_config);
844849
}
845850

846-
// Perform RSS handoff
851+
/// Perform RSS handoff
847852
pub async fn start_nexus_external(
848853
&mut self,
849854
tls_certificates: Vec<Certificate>,
@@ -881,11 +886,11 @@ impl<'a, N: NexusServer> ControlPlaneTestContextBuilder<'a, N> {
881886
// The first sled agent is the only one that'll have configured
882887
// blueprint zones, but the others all need to have disks.
883888

884-
let maybe_zones = std::iter::once(Some(&self.blueprint_zones))
885-
.chain(std::iter::repeat(None));
889+
let maybe_zones =
890+
once(Some(&self.blueprint_zones)).chain(repeat(None));
886891

887892
for (sled_agent, maybe_zones) in
888-
std::iter::zip(self.sled_agents.iter(), maybe_zones)
893+
zip(self.sled_agents.iter(), maybe_zones)
889894
{
890895
let sled_id = sled_agent.sled_agent_id();
891896

@@ -947,11 +952,13 @@ impl<'a, N: NexusServer> ControlPlaneTestContextBuilder<'a, N> {
947952
}
948953
}
949954

955+
self.blueprint_disks.insert(sled_id, disks.clone());
956+
self.blueprint_datasets.insert(sled_id, datasets.clone());
950957
blueprint_sleds.insert(
951958
sled_id,
952959
BlueprintSledConfig {
953960
state: SledState::Active,
954-
sled_agent_generation: Generation::new().next(),
961+
sled_agent_generation: 4.into(),
955962
disks,
956963
datasets,
957964
zones,
@@ -1099,33 +1106,6 @@ impl<'a, N: NexusServer> ControlPlaneTestContextBuilder<'a, N> {
10991106
/// tell the other Sled Agents to report they have no zones configured, and
11001107
/// write the early network config to all sleds.
11011108
pub async fn configure_sled_agents(&mut self) {
1102-
let Some(sled_agent) = self.sled_agents.first() else {
1103-
panic!("expected sled agent has not been created");
1104-
};
1105-
1106-
let client = sled_agent_client::Client::new(
1107-
&format!("http://{}", sled_agent.local_addr()),
1108-
self.logctx.log.clone(),
1109-
);
1110-
1111-
client
1112-
.omicron_config_put(&OmicronSledConfig {
1113-
generation: Generation::new().next(),
1114-
// Sending no disks or datasets is probably wrong, but there are
1115-
// a lot of inconsistencies with this in nexus-test.
1116-
disks: IdMap::default(),
1117-
datasets: IdMap::default(),
1118-
zones: self
1119-
.blueprint_zones
1120-
.clone()
1121-
.into_iter()
1122-
.map(From::from)
1123-
.collect(),
1124-
remove_mupdate_override: None,
1125-
})
1126-
.await
1127-
.expect("Failed to configure sled agent with our zones");
1128-
11291109
let early_network_config = EarlyNetworkConfig {
11301110
body: EarlyNetworkConfigBody {
11311111
ntp_servers: Vec::new(),
@@ -1142,33 +1122,40 @@ impl<'a, N: NexusServer> ControlPlaneTestContextBuilder<'a, N> {
11421122
schema_version: 2,
11431123
};
11441124

1145-
client
1146-
.write_network_bootstore_config(&early_network_config)
1147-
.await
1148-
.expect("Failed to write early networking config to bootstore");
1125+
macro_rules! from_clone {
1126+
($source: expr) => {
1127+
$source.clone().into_iter().map(From::from).collect()
1128+
};
1129+
}
11491130

1150-
for sled_agent in self.sled_agents.iter().skip(1) {
1131+
let generation = Generation::from_u32(2);
1132+
let zones =
1133+
once(from_clone!(self.blueprint_zones)).chain(repeat(vec![]));
1134+
for (sled_agent, sled_zones) in zip(self.sled_agents.iter(), zones) {
1135+
let sled_id = sled_agent.sled_agent_id();
11511136
let client = sled_agent_client::Client::new(
11521137
&format!("http://{}", sled_agent.local_addr()),
11531138
self.logctx.log.clone(),
11541139
);
11551140

11561141
client
11571142
.omicron_config_put(&OmicronSledConfig {
1158-
generation: Generation::new().next(),
1159-
// As above, sending no disks or datasets is probably wrong
1160-
disks: IdMap::default(),
1161-
datasets: IdMap::default(),
1162-
zones: IdMap::default(),
1143+
generation,
1144+
disks: from_clone!(self.blueprint_disks[&sled_id]),
1145+
datasets: from_clone!(self.blueprint_datasets[&sled_id]),
1146+
zones: sled_zones.into_iter().collect(),
11631147
remove_mupdate_override: None,
11641148
})
11651149
.await
1166-
.expect("Failed to configure sled agent with our zones");
1150+
.expect("Failed to configure sled agent {sled_id} with zones");
11671151

11681152
client
11691153
.write_network_bootstore_config(&early_network_config)
11701154
.await
1171-
.expect("Failed to write early networking config to bootstore");
1155+
.expect(
1156+
"Failed to write early networking config \
1157+
to bootstore on sled {sled_id}",
1158+
);
11721159
}
11731160
}
11741161

@@ -1741,7 +1728,7 @@ async fn setup_with_config_impl<N: NexusServer>(
17411728
}
17421729

17431730
// Start expected services: these will all be allocated to the first sled
1744-
// agent. Afterwards, configure the first sled agent, and start the rest of
1731+
// agent. Afterwards, configure the sled agents and start the rest of the
17451732
// the required services.
17461733

17471734
builder
@@ -1761,10 +1748,6 @@ async fn setup_with_config_impl<N: NexusServer>(
17611748
"populate_internal_dns",
17621749
Box::new(|builder| builder.populate_internal_dns().boxed()),
17631750
),
1764-
(
1765-
"configure_sled_agents",
1766-
Box::new(|builder| builder.configure_sled_agents().boxed()),
1767-
),
17681751
(
17691752
"start_nexus_external",
17701753
Box::new(|builder| {
@@ -1775,6 +1758,10 @@ async fn setup_with_config_impl<N: NexusServer>(
17751758
.boxed()
17761759
}),
17771760
),
1761+
(
1762+
"configure_sled_agents",
1763+
Box::new(|builder| builder.configure_sled_agents().boxed()),
1764+
),
17781765
(
17791766
"start_oximeter",
17801767
Box::new(|builder| builder.start_oximeter().boxed()),

0 commit comments

Comments
 (0)