Skip to content

Commit

Permalink
[4/n] [reconfigurator] more control over ExampleSystem zone allocation (
Browse files Browse the repository at this point in the history
#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.
  • Loading branch information
sunshowers authored Oct 9, 2024
1 parent 2dcf896 commit 93d6974
Show file tree
Hide file tree
Showing 6 changed files with 536 additions and 85 deletions.
11 changes: 5 additions & 6 deletions nexus/reconfigurator/planning/src/blueprint_builder/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1646,12 +1646,11 @@ impl<'a> BlueprintBuilder<'a> {
/// ordinarily only come from RSS.
///
/// TODO-cleanup: Remove when external DNS addresses are in the policy.
#[cfg(test)]
#[track_caller]
pub fn add_external_dns_ip(&mut self, addr: IpAddr) {
self.external_networking()
.expect("failed to initialize external networking allocator")
.add_external_dns_ip(addr);
pub(crate) fn add_external_dns_ip(
&mut self,
addr: IpAddr,
) -> Result<(), Error> {
self.external_networking()?.add_external_dns_ip(addr)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use super::Error;
use anyhow::anyhow;
use anyhow::bail;
use debug_ignore::DebugIgnore;
use nexus_config::NUM_INITIAL_RESERVED_IP_ADDRESSES;
Expand Down Expand Up @@ -371,12 +372,18 @@ impl<'a> BuilderExternalNetworking<'a> {
/// which could otherwise only be added via RSS.
///
/// TODO-cleanup: Remove when external DNS addresses are in the policy.
#[cfg(test)]
pub fn add_external_dns_ip(&mut self, addr: IpAddr) {
assert!(
self.available_external_dns_ips.insert(addr),
"duplicate external DNS IP address"
);
pub(crate) fn add_external_dns_ip(
&mut self,
addr: IpAddr,
) -> Result<(), Error> {
if self.available_external_dns_ips.contains(&addr) {
return Err(Error::Planner(anyhow!(
"external DNS IP address already in use: {addr}"
)));
}

self.available_external_dns_ips.insert(addr);
Ok(())
}
}

Expand Down
Loading

0 comments on commit 93d6974

Please sign in to comment.