Skip to content

Commit 93d6974

Browse files
authored
[4/n] [reconfigurator] more control over ExampleSystem zone allocation (#6785)
`ExampleSystem` instances now allow for controlling the number of Nexus and DNS zones. There was one test that manually poked at the `ExampleSystem` earlier -- that test can now switch to using this scheme. (I didn't realize it at the time but we were allocating just one Nexus zone per sled -- I thought we were doing 3 total. Well, now it's clear how many zones are being allocated.) Also add tests to ensure zone allocation works properly.
1 parent 2dcf896 commit 93d6974

File tree

6 files changed

+536
-85
lines changed

6 files changed

+536
-85
lines changed

nexus/reconfigurator/planning/src/blueprint_builder/builder.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,12 +1646,11 @@ impl<'a> BlueprintBuilder<'a> {
16461646
/// ordinarily only come from RSS.
16471647
///
16481648
/// TODO-cleanup: Remove when external DNS addresses are in the policy.
1649-
#[cfg(test)]
1650-
#[track_caller]
1651-
pub fn add_external_dns_ip(&mut self, addr: IpAddr) {
1652-
self.external_networking()
1653-
.expect("failed to initialize external networking allocator")
1654-
.add_external_dns_ip(addr);
1649+
pub(crate) fn add_external_dns_ip(
1650+
&mut self,
1651+
addr: IpAddr,
1652+
) -> Result<(), Error> {
1653+
self.external_networking()?.add_external_dns_ip(addr)
16551654
}
16561655
}
16571656

nexus/reconfigurator/planning/src/blueprint_builder/external_networking.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

55
use super::Error;
6+
use anyhow::anyhow;
67
use anyhow::bail;
78
use debug_ignore::DebugIgnore;
89
use nexus_config::NUM_INITIAL_RESERVED_IP_ADDRESSES;
@@ -371,12 +372,18 @@ impl<'a> BuilderExternalNetworking<'a> {
371372
/// which could otherwise only be added via RSS.
372373
///
373374
/// TODO-cleanup: Remove when external DNS addresses are in the policy.
374-
#[cfg(test)]
375-
pub fn add_external_dns_ip(&mut self, addr: IpAddr) {
376-
assert!(
377-
self.available_external_dns_ips.insert(addr),
378-
"duplicate external DNS IP address"
379-
);
375+
pub(crate) fn add_external_dns_ip(
376+
&mut self,
377+
addr: IpAddr,
378+
) -> Result<(), Error> {
379+
if self.available_external_dns_ips.contains(&addr) {
380+
return Err(Error::Planner(anyhow!(
381+
"external DNS IP address already in use: {addr}"
382+
)));
383+
}
384+
385+
self.available_external_dns_ips.insert(addr);
386+
Ok(())
380387
}
381388
}
382389

0 commit comments

Comments
 (0)