Skip to content

Commit 041e406

Browse files
authored
Restore initial planning input population of external networking records (#6742)
Recapping from the update sync: * #6483 moved the code restored by this PR into a helper method (`update_network_resources_from_blueprint()`), and also added calls to that method to a handful of tests to make them pass * In the external DNS work, we discovered that those tests should not have needed that, and the reason they did was because of a different bug * #6599 fixed that bug and removed `update_network_resources_from_blueprint()` and all its callers, but neglected to restore this code, meaning the `PlanningInput`s our tests create from their initial system descriptions never had any external networking records
1 parent c50cf01 commit 041e406

File tree

2 files changed

+61
-28
lines changed

2 files changed

+61
-28
lines changed

nexus/reconfigurator/planning/src/example.rs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ use crate::system::SledBuilder;
99
use crate::system::SystemDescription;
1010
use nexus_types::deployment::Blueprint;
1111
use nexus_types::deployment::BlueprintZoneFilter;
12+
use nexus_types::deployment::OmicronZoneNic;
1213
use nexus_types::deployment::PlanningInput;
1314
use nexus_types::deployment::SledFilter;
1415
use nexus_types::inventory::Collection;
1516
use omicron_common::policy::INTERNAL_DNS_REDUNDANCY;
17+
use omicron_uuid_kinds::GenericUuid;
1618
use omicron_uuid_kinds::SledKind;
19+
use omicron_uuid_kinds::VnicUuid;
1720
use typed_rng::TypedUuidRng;
1821

1922
pub struct ExampleSystem {
@@ -44,7 +47,7 @@ impl ExampleSystem {
4447
let _ = system.sled(SledBuilder::new().id(*sled_id)).unwrap();
4548
}
4649

47-
let input_builder = system
50+
let mut input_builder = system
4851
.to_planning_input_builder()
4952
.expect("failed to make planning input builder");
5053
let base_input = input_builder.clone().build();
@@ -102,6 +105,35 @@ impl ExampleSystem {
102105
system.to_collection_builder().expect("failed to build collection");
103106
builder.set_rng_seed((test_name, "ExampleSystem collection"));
104107

108+
for sled_id in blueprint.sleds() {
109+
let Some(zones) = blueprint.blueprint_zones.get(&sled_id) else {
110+
continue;
111+
};
112+
for zone in zones.zones.iter() {
113+
let service_id = zone.id;
114+
if let Some((external_ip, nic)) =
115+
zone.zone_type.external_networking()
116+
{
117+
input_builder
118+
.add_omicron_zone_external_ip(service_id, external_ip)
119+
.expect("failed to add Omicron zone external IP");
120+
input_builder
121+
.add_omicron_zone_nic(
122+
service_id,
123+
OmicronZoneNic {
124+
// TODO-cleanup use `TypedUuid` everywhere
125+
id: VnicUuid::from_untyped_uuid(nic.id),
126+
mac: nic.mac,
127+
ip: nic.ip,
128+
slot: nic.slot,
129+
primary: nic.primary,
130+
},
131+
)
132+
.expect("failed to add Omicron zone NIC");
133+
}
134+
}
135+
}
136+
105137
for (sled_id, zones) in &blueprint.blueprint_zones {
106138
builder
107139
.found_sled_omicron_zones(

nexus/src/app/background/tasks/blueprint_execution.rs

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,34 @@ mod test {
282282
// sleds to CRDB.
283283
let mut s1 = httptest::Server::run();
284284
let mut s2 = httptest::Server::run();
285+
286+
// The only sled-agent endpoint we care about in this test is `PUT
287+
// /omicron-zones`. Add a closure to avoid repeating it multiple times
288+
// below. We don't do a careful check of the _contents_ of what's being
289+
// sent; for that, see the tests in nexus-reconfigurator-execution.
290+
let match_put_omicron_zones =
291+
|| request::method_path("PUT", "/omicron-zones");
292+
293+
// Helper for our mock sled-agent http servers to blanket ignore and
294+
// return 200 OK for anything _except_ `PUT /omciron-zones`, which is
295+
// the endpoint we care about in this test.
296+
//
297+
// Other Nexus background tasks created by our test context may notice
298+
// the sled-agent records we're about to insert into CRDB and query them
299+
// (e.g., for inventory, vpc routing info, ...). We don't want those to
300+
// cause spurious test failures, so just tell our sled-agents to accept
301+
// any number of them.
302+
let mock_server_ignore_spurious_http_requests =
303+
|s: &mut httptest::Server| {
304+
s.expect(
305+
Expectation::matching(not(match_put_omicron_zones()))
306+
.times(..)
307+
.respond_with(status_code(200)),
308+
);
309+
};
310+
mock_server_ignore_spurious_http_requests(&mut s1);
311+
mock_server_ignore_spurious_http_requests(&mut s2);
312+
285313
let sled_id1 = SledUuid::new_v4();
286314
let sled_id2 = SledUuid::new_v4();
287315
let rack_id = Uuid::new_v4();
@@ -410,33 +438,6 @@ mod test {
410438
)
411439
.await;
412440

413-
// The only sled-agent endpoint we care about in this test is `PUT
414-
// /omicron-zones`. Add a closure to avoid repeating it multiple times
415-
// below. We don't do a careful check of the _contents_ of what's being
416-
// sent; for that, see the tests in nexus-reconfigurator-execution.
417-
let match_put_omicron_zones =
418-
|| request::method_path("PUT", "/omicron-zones");
419-
420-
// Helper for our mock sled-agent http servers to blanket ignore and
421-
// return 200 OK for anything _except_ `PUT /omciron-zones`, which is
422-
// the endpoint we care about in this test.
423-
//
424-
// Other Nexus background tasks created by our test context may notice
425-
// the sled-agent records we're about to insert into CRDB and query them
426-
// (e.g., for inventory, vpc routing info, ...). We don't want those to
427-
// cause spurious test failures, so just tell our sled-agents to accept
428-
// any number of them.
429-
let mock_server_ignore_spurious_http_requests =
430-
|s: &mut httptest::Server| {
431-
s.expect(
432-
Expectation::matching(not(match_put_omicron_zones()))
433-
.times(..)
434-
.respond_with(status_code(200)),
435-
);
436-
};
437-
mock_server_ignore_spurious_http_requests(&mut s1);
438-
mock_server_ignore_spurious_http_requests(&mut s2);
439-
440441
// Insert records for the zpools backing the datasets in these zones.
441442
for (sled_id, config) in
442443
blueprint.1.all_omicron_zones(BlueprintZoneFilter::All)

0 commit comments

Comments
 (0)