Skip to content

Commit

Permalink
Rename (MAX_)DNS_REDUNDANCY → (MAX_)INTERNAL_DNS_REDUNDANCY
Browse files Browse the repository at this point in the history
  • Loading branch information
plotnick committed Aug 28, 2024
1 parent ff00ffe commit cc20875
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 32 deletions.
8 changes: 4 additions & 4 deletions common/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//! and Nexus, who need to agree upon addressing schemes.
use crate::api::external::{self, Error};
use crate::policy::{DNS_REDUNDANCY, MAX_DNS_REDUNDANCY};
use crate::policy::{INTERNAL_DNS_REDUNDANCY, MAX_INTERNAL_DNS_REDUNDANCY};
use ipnetwork::Ipv6Network;
use once_cell::sync::Lazy;
use oxnet::{Ipv4Net, Ipv6Net};
Expand Down Expand Up @@ -309,7 +309,7 @@ impl ReservedRackSubnet {
/// These addresses will come from the first [`MAX_DNS_REDUNDANCY`] `/64s` of the
/// [`RACK_PREFIX`] subnet.
pub fn get_dns_subnets(&self) -> Vec<DnsSubnet> {
(0..MAX_DNS_REDUNDANCY)
(0..MAX_INTERNAL_DNS_REDUNDANCY)
.map(|idx| self.get_dns_subnet(u8::try_from(idx + 1).unwrap()))
.collect()
}
Expand All @@ -321,7 +321,7 @@ pub fn get_internal_dns_server_addresses(addr: Ipv6Addr) -> Vec<IpAddr> {
let az_subnet = Ipv6Subnet::<AZ_PREFIX>::new(addr);
let reserved_rack_subnet = ReservedRackSubnet::new(az_subnet);
let dns_subnets =
&reserved_rack_subnet.get_dns_subnets()[0..DNS_REDUNDANCY];
&reserved_rack_subnet.get_dns_subnets()[0..INTERNAL_DNS_REDUNDANCY];
dns_subnets
.iter()
.map(|dns_subnet| IpAddr::from(dns_subnet.dns_address()))
Expand Down Expand Up @@ -702,7 +702,7 @@ mod test {

// Observe the first DNS subnet within this reserved rack subnet.
let dns_subnets = rack_subnet.get_dns_subnets();
assert_eq!(MAX_DNS_REDUNDANCY, dns_subnets.len());
assert_eq!(MAX_INTERNAL_DNS_REDUNDANCY, dns_subnets.len());

// The DNS address and GZ address should be only differing by one.
assert_eq!(
Expand Down
10 changes: 5 additions & 5 deletions common/src/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ pub const COCKROACHDB_REDUNDANCY: usize = 5;

/// The amount of redundancy for internal DNS servers.
///
/// Must be less than or equal to MAX_DNS_REDUNDANCY.
pub const DNS_REDUNDANCY: usize = 3;
/// Must be less than or equal to MAX_INTERNAL_DNS_REDUNDANCY.
pub const INTERNAL_DNS_REDUNDANCY: usize = 3;

/// The maximum amount of redundancy for DNS servers.
/// The maximum amount of redundancy for internal DNS servers.
///
/// This determines the number of addresses which are reserved for DNS servers.
pub const MAX_DNS_REDUNDANCY: usize = 5;
/// This determines the number of addresses which are reserved for internal DNS servers.
pub const MAX_INTERNAL_DNS_REDUNDANCY: usize = 5;

/// The amount of redundancy for clickhouse servers
///
Expand Down
4 changes: 2 additions & 2 deletions nexus/reconfigurator/execution/src/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ mod test {
use omicron_common::api::external::IdentityMetadataCreateParams;
use omicron_common::policy::BOUNDARY_NTP_REDUNDANCY;
use omicron_common::policy::COCKROACHDB_REDUNDANCY;
use omicron_common::policy::DNS_REDUNDANCY;
use omicron_common::policy::INTERNAL_DNS_REDUNDANCY;
use omicron_common::policy::NEXUS_REDUNDANCY;
use omicron_common::zpool_name::ZpoolName;
use omicron_test_utils::dev::test_setup_log;
Expand Down Expand Up @@ -1527,7 +1527,7 @@ mod test {
service_nic_rows: &[],
target_boundary_ntp_zone_count: BOUNDARY_NTP_REDUNDANCY,
target_nexus_zone_count: NEXUS_REDUNDANCY,
target_internal_dns_zone_count: DNS_REDUNDANCY,
target_internal_dns_zone_count: INTERNAL_DNS_REDUNDANCY,
target_cockroachdb_zone_count: COCKROACHDB_REDUNDANCY,
target_cockroachdb_cluster_version:
CockroachDbClusterVersion::POLICY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use omicron_common::api::external::Generation;
use omicron_common::api::external::Vni;
use omicron_common::api::internal::shared::NetworkInterface;
use omicron_common::api::internal::shared::NetworkInterfaceKind;
use omicron_common::policy::MAX_DNS_REDUNDANCY;
use omicron_common::policy::MAX_INTERNAL_DNS_REDUNDANCY;
use omicron_uuid_kinds::ExternalIpKind;
use omicron_uuid_kinds::GenericUuid;
use omicron_uuid_kinds::OmicronZoneKind;
Expand Down Expand Up @@ -113,7 +113,9 @@ pub enum Error {
Planner(#[source] anyhow::Error),
#[error("no reserved subnets available for DNS")]
NoAvailableDnsSubnets,
#[error("can only have {MAX_DNS_REDUNDANCY} internal DNS servers")]
#[error(
"can only have {MAX_INTERNAL_DNS_REDUNDANCY} internal DNS servers"
)]
TooManyDnsServers,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use nexus_types::deployment::BlueprintZoneType;
use nexus_types::deployment::PlanningInput;
use omicron_common::address::DnsSubnet;
use omicron_common::address::ReservedRackSubnet;
use omicron_common::policy::MAX_DNS_REDUNDANCY;
use omicron_common::policy::MAX_INTERNAL_DNS_REDUNDANCY;
use std::collections::BTreeSet;

/// Internal DNS zones are not allocated an address in the sled's subnet.
Expand Down Expand Up @@ -40,7 +40,7 @@ impl DnsSubnetAllocator {
.collect::<BTreeSet<DnsSubnet>>();

let redundancy = input.target_internal_dns_zone_count();
if redundancy > MAX_DNS_REDUNDANCY {
if redundancy > MAX_INTERNAL_DNS_REDUNDANCY {
return Err(Error::TooManyDnsServers);
}

Expand Down Expand Up @@ -103,7 +103,9 @@ pub mod test {
use super::*;
use crate::blueprint_builder::test::verify_blueprint;
use crate::example::ExampleSystem;
use omicron_common::policy::{DNS_REDUNDANCY, MAX_DNS_REDUNDANCY};
use omicron_common::policy::{
INTERNAL_DNS_REDUNDANCY, MAX_INTERNAL_DNS_REDUNDANCY,
};
use omicron_test_utils::dev::test_setup_log;

#[test]
Expand All @@ -113,7 +115,7 @@ pub mod test {

// Use our example system to create a blueprint and input.
let example =
ExampleSystem::new(&logctx.log, TEST_NAME, DNS_REDUNDANCY);
ExampleSystem::new(&logctx.log, TEST_NAME, INTERNAL_DNS_REDUNDANCY);
let blueprint1 = &example.blueprint;
verify_blueprint(blueprint1);

Expand All @@ -135,11 +137,11 @@ pub mod test {
);

// Allocate two new subnets.
assert_eq!(MAX_DNS_REDUNDANCY - DNS_REDUNDANCY, 2);
assert_eq!(MAX_INTERNAL_DNS_REDUNDANCY - INTERNAL_DNS_REDUNDANCY, 2);
assert_eq!(
allocator.len(),
DNS_REDUNDANCY,
"should be {DNS_REDUNDANCY} subnets allocated"
INTERNAL_DNS_REDUNDANCY,
"should be {INTERNAL_DNS_REDUNDANCY} subnets allocated"
);
let new1 =
allocator.alloc(rack_subnet).expect("failed to allocate a subnet");
Expand All @@ -154,8 +156,8 @@ pub mod test {
assert_ne!(new1, new2, "allocated duplicate subnets");
assert_eq!(
allocator.len(),
MAX_DNS_REDUNDANCY,
"should be {DNS_REDUNDANCY} subnets allocated"
MAX_INTERNAL_DNS_REDUNDANCY,
"should be {INTERNAL_DNS_REDUNDANCY} subnets allocated"
);
allocator.alloc(rack_subnet).expect_err("no subnets available");

Expand Down
4 changes: 2 additions & 2 deletions nexus/reconfigurator/planning/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ mod test {
use nexus_types::inventory::OmicronZonesFound;
use omicron_common::api::external::Generation;
use omicron_common::disk::DiskIdentity;
use omicron_common::policy::MAX_DNS_REDUNDANCY;
use omicron_common::policy::MAX_INTERNAL_DNS_REDUNDANCY;
use omicron_test_utils::dev::test_setup_log;
use omicron_uuid_kinds::GenericUuid;
use omicron_uuid_kinds::PhysicalDiskUuid;
Expand Down Expand Up @@ -1198,7 +1198,7 @@ mod test {
// Try again with a reasonable number.
let mut builder = input.into_builder();
builder.policy_mut().target_internal_dns_zone_count =
MAX_DNS_REDUNDANCY;
MAX_INTERNAL_DNS_REDUNDANCY;
let blueprint2 = Planner::new_based_on(
logctx.log.clone(),
&blueprint1,
Expand Down
4 changes: 2 additions & 2 deletions nexus/reconfigurator/planning/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use omicron_common::api::external::ByteCount;
use omicron_common::api::external::Generation;
use omicron_common::disk::DiskIdentity;
use omicron_common::disk::DiskVariant;
use omicron_common::policy::DNS_REDUNDANCY;
use omicron_common::policy::INTERNAL_DNS_REDUNDANCY;
use omicron_common::policy::NEXUS_REDUNDANCY;
use omicron_uuid_kinds::GenericUuid;
use omicron_uuid_kinds::PhysicalDiskUuid;
Expand Down Expand Up @@ -132,7 +132,7 @@ impl SystemDescription {

// Policy defaults
let target_nexus_zone_count = NEXUS_REDUNDANCY;
let target_internal_dns_zone_count = DNS_REDUNDANCY;
let target_internal_dns_zone_count = INTERNAL_DNS_REDUNDANCY;

// TODO-cleanup These are wrong, but we don't currently set up any
// boundary NTP or CRDB nodes in our fake system, so this prevents
Expand Down
4 changes: 2 additions & 2 deletions nexus/reconfigurator/preparation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use omicron_common::api::external::LookupType;
use omicron_common::disk::DiskIdentity;
use omicron_common::policy::BOUNDARY_NTP_REDUNDANCY;
use omicron_common::policy::COCKROACHDB_REDUNDANCY;
use omicron_common::policy::DNS_REDUNDANCY;
use omicron_common::policy::INTERNAL_DNS_REDUNDANCY;
use omicron_common::policy::NEXUS_REDUNDANCY;
use omicron_uuid_kinds::GenericUuid;
use omicron_uuid_kinds::OmicronZoneUuid;
Expand Down Expand Up @@ -127,7 +127,7 @@ impl PlanningInputFromDb<'_> {
ip_pool_range_rows: &ip_pool_range_rows,
target_boundary_ntp_zone_count: BOUNDARY_NTP_REDUNDANCY,
target_nexus_zone_count: NEXUS_REDUNDANCY,
target_internal_dns_zone_count: DNS_REDUNDANCY,
target_internal_dns_zone_count: INTERNAL_DNS_REDUNDANCY,
target_cockroachdb_zone_count: COCKROACHDB_REDUNDANCY,
target_cockroachdb_cluster_version:
CockroachDbClusterVersion::POLICY,
Expand Down
10 changes: 6 additions & 4 deletions sled-agent/src/rack_setup/plan/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ use omicron_common::disk::{
};
use omicron_common::ledger::{self, Ledger, Ledgerable};
use omicron_common::policy::{
BOUNDARY_NTP_REDUNDANCY, COCKROACHDB_REDUNDANCY, DNS_REDUNDANCY,
MAX_DNS_REDUNDANCY, NEXUS_REDUNDANCY,
BOUNDARY_NTP_REDUNDANCY, COCKROACHDB_REDUNDANCY, INTERNAL_DNS_REDUNDANCY,
MAX_INTERNAL_DNS_REDUNDANCY, NEXUS_REDUNDANCY,
};
use omicron_uuid_kinds::{
ExternalIpUuid, GenericUuid, OmicronZoneUuid, SledUuid, ZpoolUuid,
Expand Down Expand Up @@ -470,9 +470,11 @@ impl Plan {

// Provision internal DNS zones, striping across Sleds.
let reserved_rack_subnet = ReservedRackSubnet::new(config.az_subnet());
static_assertions::const_assert!(DNS_REDUNDANCY <= MAX_DNS_REDUNDANCY,);
static_assertions::const_assert!(
INTERNAL_DNS_REDUNDANCY <= MAX_INTERNAL_DNS_REDUNDANCY
);
let dns_subnets =
&reserved_rack_subnet.get_dns_subnets()[0..DNS_REDUNDANCY];
&reserved_rack_subnet.get_dns_subnets()[0..INTERNAL_DNS_REDUNDANCY];
let rack_dns_servers = dns_subnets
.into_iter()
.map(|dns_subnet| dns_subnet.dns_address().into())
Expand Down

0 comments on commit cc20875

Please sign in to comment.