From cc208751110a05b2c0e84c09c8b07fda14f7de57 Mon Sep 17 00:00:00 2001 From: Alex Plotnick Date: Wed, 28 Aug 2024 17:36:02 -0600 Subject: [PATCH] =?UTF-8?q?Rename=20(MAX=5F)DNS=5FREDUNDANCY=20=E2=86=92?= =?UTF-8?q?=20(MAX=5F)INTERNAL=5FDNS=5FREDUNDANCY?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/src/address.rs | 8 ++++---- common/src/policy.rs | 10 +++++----- nexus/reconfigurator/execution/src/dns.rs | 4 ++-- .../planning/src/blueprint_builder/builder.rs | 6 ++++-- .../src/blueprint_builder/internal_dns.rs | 20 ++++++++++--------- nexus/reconfigurator/planning/src/planner.rs | 4 ++-- nexus/reconfigurator/planning/src/system.rs | 4 ++-- nexus/reconfigurator/preparation/src/lib.rs | 4 ++-- sled-agent/src/rack_setup/plan/service.rs | 10 ++++++---- 9 files changed, 38 insertions(+), 32 deletions(-) diff --git a/common/src/address.rs b/common/src/address.rs index a75fbbe212f..cb55f2b36b4 100644 --- a/common/src/address.rs +++ b/common/src/address.rs @@ -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}; @@ -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 { - (0..MAX_DNS_REDUNDANCY) + (0..MAX_INTERNAL_DNS_REDUNDANCY) .map(|idx| self.get_dns_subnet(u8::try_from(idx + 1).unwrap())) .collect() } @@ -321,7 +321,7 @@ pub fn get_internal_dns_server_addresses(addr: Ipv6Addr) -> Vec { let az_subnet = Ipv6Subnet::::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())) @@ -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!( diff --git a/common/src/policy.rs b/common/src/policy.rs index 677dbfe2b9f..e615981a21c 100644 --- a/common/src/policy.rs +++ b/common/src/policy.rs @@ -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 /// diff --git a/nexus/reconfigurator/execution/src/dns.rs b/nexus/reconfigurator/execution/src/dns.rs index 2510b18528f..aab3839bd04 100644 --- a/nexus/reconfigurator/execution/src/dns.rs +++ b/nexus/reconfigurator/execution/src/dns.rs @@ -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; @@ -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, diff --git a/nexus/reconfigurator/planning/src/blueprint_builder/builder.rs b/nexus/reconfigurator/planning/src/blueprint_builder/builder.rs index e3944fb58c0..c7eb5bddad9 100644 --- a/nexus/reconfigurator/planning/src/blueprint_builder/builder.rs +++ b/nexus/reconfigurator/planning/src/blueprint_builder/builder.rs @@ -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; @@ -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, } diff --git a/nexus/reconfigurator/planning/src/blueprint_builder/internal_dns.rs b/nexus/reconfigurator/planning/src/blueprint_builder/internal_dns.rs index 4db2689d910..b4286d16c44 100644 --- a/nexus/reconfigurator/planning/src/blueprint_builder/internal_dns.rs +++ b/nexus/reconfigurator/planning/src/blueprint_builder/internal_dns.rs @@ -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. @@ -40,7 +40,7 @@ impl DnsSubnetAllocator { .collect::>(); let redundancy = input.target_internal_dns_zone_count(); - if redundancy > MAX_DNS_REDUNDANCY { + if redundancy > MAX_INTERNAL_DNS_REDUNDANCY { return Err(Error::TooManyDnsServers); } @@ -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] @@ -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); @@ -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"); @@ -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"); diff --git a/nexus/reconfigurator/planning/src/planner.rs b/nexus/reconfigurator/planning/src/planner.rs index 16dd3370658..7149aecb851 100644 --- a/nexus/reconfigurator/planning/src/planner.rs +++ b/nexus/reconfigurator/planning/src/planner.rs @@ -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; @@ -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, diff --git a/nexus/reconfigurator/planning/src/system.rs b/nexus/reconfigurator/planning/src/system.rs index 4de2ebff8e3..26e4910c5bd 100644 --- a/nexus/reconfigurator/planning/src/system.rs +++ b/nexus/reconfigurator/planning/src/system.rs @@ -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; @@ -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 diff --git a/nexus/reconfigurator/preparation/src/lib.rs b/nexus/reconfigurator/preparation/src/lib.rs index 5e1b1321cf2..7fa22b8441a 100644 --- a/nexus/reconfigurator/preparation/src/lib.rs +++ b/nexus/reconfigurator/preparation/src/lib.rs @@ -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; @@ -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, diff --git a/sled-agent/src/rack_setup/plan/service.rs b/sled-agent/src/rack_setup/plan/service.rs index 7bf3a7a8759..7ca2b295a04 100644 --- a/sled-agent/src/rack_setup/plan/service.rs +++ b/sled-agent/src/rack_setup/plan/service.rs @@ -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, @@ -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())