Skip to content

Commit 7c6db64

Browse files
authored
add DNS names for TUF repo depot (#7939)
1 parent 55ba0c6 commit 7c6db64

File tree

11 files changed

+156
-9
lines changed

11 files changed

+156
-9
lines changed

dev-tools/reconfigurator-cli/src/lib.rs

+7
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ use nexus_types::deployment::execution;
3434
use nexus_types::deployment::execution::blueprint_external_dns_config;
3535
use nexus_types::deployment::execution::blueprint_internal_dns_config;
3636
use nexus_types::deployment::{Blueprint, UnstableReconfiguratorState};
37+
use nexus_types::external_api::views::SledPolicy;
38+
use nexus_types::external_api::views::SledProvisionPolicy;
39+
use omicron_common::address::REPO_DEPOT_PORT;
3740
use omicron_common::api::external::Generation;
3841
use omicron_common::api::external::Name;
3942
use omicron_common::policy::NEXUS_REDUNDANCY;
@@ -1082,7 +1085,11 @@ fn make_sleds_by_id(
10821085
.map(|(sled_id, sled_agent_info)| {
10831086
let sled = execution::Sled::new(
10841087
*sled_id,
1088+
SledPolicy::InService {
1089+
provision_policy: SledProvisionPolicy::Provisionable,
1090+
},
10851091
sled_agent_info.sled_agent_address,
1092+
REPO_DEPOT_PORT,
10861093
sled_agent_info.sled_role,
10871094
);
10881095
(*sled_id, sled)

dev-tools/reconfigurator-cli/tests/output/cmd-set-zone-images-stdout

+8
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ internal DNS:
312312
AAAA fd00:1122:3344:101::26
313313
name: 805cba8f-a039-44e1-8cb0-1ff2c6b89997.host (records: 1)
314314
AAAA fd00:1122:3344:101::23
315+
name: 868d5b02-7792-4fc0-b6a9-654afcae9ea0.sled (records: 1)
316+
AAAA fd00:1122:3344:101::1
315317
name: _clickhouse-admin-single-server._tcp (records: 1)
316318
SRV port 8888 4fc6cb68-8ce9-4171-91b3-0106b8fed386.host.control-plane.oxide.internal
317319
name: _clickhouse-native._tcp (records: 1)
@@ -342,6 +344,8 @@ internal DNS:
342344
SRV port 12221 296ab8b3-3fd4-4c2b-9e0a-1f909e4993e5.host.control-plane.oxide.internal
343345
SRV port 12221 50dcee18-a857-4596-8cb7-fc9cf90b698d.host.control-plane.oxide.internal
344346
SRV port 12221 805cba8f-a039-44e1-8cb0-1ff2c6b89997.host.control-plane.oxide.internal
347+
name: _repo-depot._tcp (records: 1)
348+
SRV port 12348 868d5b02-7792-4fc0-b6a9-654afcae9ea0.sled.control-plane.oxide.internal
345349
name: ac0f0ca6-02dd-43c7-b029-f34b247f7392.host (records: 1)
346350
AAAA fd00:1122:3344:101::28
347351
name: ae74917b-2c6a-477d-9b90-fe2c2a4247f7.host (records: 1)
@@ -580,6 +584,8 @@ internal DNS:
580584
AAAA fd00:1122:3344:101::26
581585
name: 805cba8f-a039-44e1-8cb0-1ff2c6b89997.host (records: 1)
582586
AAAA fd00:1122:3344:101::23
587+
name: 868d5b02-7792-4fc0-b6a9-654afcae9ea0.sled (records: 1)
588+
AAAA fd00:1122:3344:101::1
583589
name: _clickhouse-admin-single-server._tcp (records: 1)
584590
SRV port 8888 4fc6cb68-8ce9-4171-91b3-0106b8fed386.host.control-plane.oxide.internal
585591
name: _clickhouse-native._tcp (records: 1)
@@ -610,6 +616,8 @@ internal DNS:
610616
SRV port 12221 296ab8b3-3fd4-4c2b-9e0a-1f909e4993e5.host.control-plane.oxide.internal
611617
SRV port 12221 50dcee18-a857-4596-8cb7-fc9cf90b698d.host.control-plane.oxide.internal
612618
SRV port 12221 805cba8f-a039-44e1-8cb0-1ff2c6b89997.host.control-plane.oxide.internal
619+
name: _repo-depot._tcp (records: 1)
620+
SRV port 12348 868d5b02-7792-4fc0-b6a9-654afcae9ea0.sled.control-plane.oxide.internal
613621
name: ac0f0ca6-02dd-43c7-b029-f34b247f7392.host (records: 1)
614622
AAAA fd00:1122:3344:101::28
615623
name: ae74917b-2c6a-477d-9b90-fe2c2a4247f7.host (records: 1)

internal-dns/types/src/names.rs

+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub enum ServiceName {
4949
Nexus,
5050
Oximeter,
5151
ManagementGatewayService,
52+
RepoDepot,
5253
Wicketd,
5354
Dendrite,
5455
Tfport,
@@ -80,6 +81,7 @@ impl ServiceName {
8081
ServiceName::Nexus => "nexus",
8182
ServiceName::Oximeter => "oximeter",
8283
ServiceName::ManagementGatewayService => "mgs",
84+
ServiceName::RepoDepot => "repo-depot",
8385
ServiceName::Wicketd => "wicketd",
8486
ServiceName::Dendrite => "dendrite",
8587
ServiceName::Tfport => "tfport",
@@ -111,6 +113,7 @@ impl ServiceName {
111113
| ServiceName::Nexus
112114
| ServiceName::Oximeter
113115
| ServiceName::ManagementGatewayService
116+
| ServiceName::RepoDepot
114117
| ServiceName::Wicketd
115118
| ServiceName::Dendrite
116119
| ServiceName::Tfport

nexus/db-model/src/sled.rs

+2
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ impl From<Sled> for execution::Sled {
149149
fn from(sled: Sled) -> Self {
150150
Self::new(
151151
SledUuid::from_untyped_uuid(sled.id()),
152+
sled.policy(),
152153
sled.address(),
154+
*sled.repo_depot_port,
153155
if sled.is_scrimlet {
154156
SledRole::Scrimlet
155157
} else {

nexus/reconfigurator/execution/src/dns.rs

+37-3
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ mod test {
343343
use nexus_types::deployment::blueprint_zone_type;
344344
use nexus_types::external_api::params;
345345
use nexus_types::external_api::shared;
346+
use nexus_types::external_api::views::SledPolicy;
347+
use nexus_types::external_api::views::SledProvisionPolicy;
346348
use nexus_types::external_api::views::SledState;
347349
use nexus_types::identity::Resource;
348350
use nexus_types::internal_api::params::DnsConfigParams;
@@ -353,6 +355,7 @@ mod test {
353355
use omicron_common::address::IpRange;
354356
use omicron_common::address::Ipv6Subnet;
355357
use omicron_common::address::RACK_PREFIX;
358+
use omicron_common::address::REPO_DEPOT_PORT;
356359
use omicron_common::address::SLED_PREFIX;
357360
use omicron_common::address::get_sled_address;
358361
use omicron_common::address::get_switch_zone_address;
@@ -733,7 +736,11 @@ mod test {
733736
.map(|(i, (sled_id, subnet))| {
734737
let sled_info = Sled::new(
735738
*sled_id,
739+
SledPolicy::InService {
740+
provision_policy: SledProvisionPolicy::Provisionable,
741+
},
736742
get_sled_address(Ipv6Subnet::new(subnet.network())),
743+
REPO_DEPOT_PORT,
737744
// The first two of these (arbitrarily) will be marked
738745
// Scrimlets.
739746
if i < 2 { SledRole::Scrimlet } else { SledRole::Gimlet },
@@ -759,7 +766,8 @@ mod test {
759766
//
760767
// 2. Every SRV record that we find should have a "target" that points
761768
// to another name within the DNS configuration, and that name should
762-
// be one of the ones with a AAAA record pointing to an Omicron zone.
769+
// be one of the ones with a AAAA record pointing to either an
770+
// Omicron zone or a global zone.
763771
//
764772
// 3. There is at least one SRV record for each service that we expect
765773
// to appear in the representative system that we're working with.
@@ -784,7 +792,7 @@ mod test {
784792
.collect();
785793
println!("omicron zones by IP: {:#?}", omicron_zones_by_ip);
786794

787-
// Check to see that the out-of-service zone was actually excluded
795+
// Check to see that the out-of-service zone was actually excluded.
788796
assert!(
789797
omicron_zones_by_ip.values().all(|id| *id != out_of_service_id)
790798
);
@@ -805,6 +813,17 @@ mod test {
805813
})
806814
.collect();
807815

816+
// We also want a mapping from underlay IP to each sled global zone.
817+
// In this case, the value is the sled id.
818+
let mut all_sleds_by_ip: BTreeMap<_, _> = sleds_by_id
819+
.keys()
820+
.map(|sled_id| {
821+
let sled_subnet = sleds_by_id.get(sled_id).unwrap().subnet();
822+
let global_zone_ip = *get_sled_address(sled_subnet).ip();
823+
(global_zone_ip, *sled_id)
824+
})
825+
.collect();
826+
808827
// Prune the special boundary NTP DNS name out, collecting their IP
809828
// addresses, and build a list of expected SRV targets to ensure these
810829
// IPs show up both in the special boundary NTP DNS name and as their
@@ -872,9 +891,23 @@ mod test {
872891
continue;
873892
}
874893

894+
if let Some(sled_id) = all_sleds_by_ip.remove(addr) {
895+
println!(
896+
"IP {} found in DNS corresponds with global zone \
897+
for sled {}",
898+
addr, sled_id
899+
);
900+
expected_srv_targets.insert(format!(
901+
"{}.{}",
902+
name, blueprint_dns_zone.zone_name
903+
));
904+
continue;
905+
}
906+
875907
println!(
876908
"note: found IP ({}) not corresponding to any \
877-
Omicron zone or switch zone (name {:?})",
909+
Omicron zone, switch zone, or global zone \
910+
(name {:?})",
878911
addr, name
879912
);
880913
}
@@ -924,6 +957,7 @@ mod test {
924957
ServiceName::CruciblePantry,
925958
ServiceName::BoundaryNtp,
926959
ServiceName::InternalNtp,
960+
ServiceName::RepoDepot,
927961
]);
928962

929963
for (name, records) in &blueprint_dns_zone.records {

nexus/reconfigurator/execution/src/omicron_sled_config.rs

+7
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,10 @@ mod tests {
159159
use nexus_types::deployment::BlueprintZoneImageSource;
160160
use nexus_types::deployment::BlueprintZoneType;
161161
use nexus_types::deployment::blueprint_zone_type;
162+
use nexus_types::external_api::views::SledPolicy;
163+
use nexus_types::external_api::views::SledProvisionPolicy;
162164
use nexus_types::external_api::views::SledState;
165+
use omicron_common::address::REPO_DEPOT_PORT;
163166
use omicron_common::api::external::Generation;
164167
use omicron_common::api::internal::shared::DatasetKind;
165168
use omicron_common::disk::CompressionAlgorithm;
@@ -194,7 +197,11 @@ mod tests {
194197
sim_sled_agent.id,
195198
Sled::new(
196199
sim_sled_agent.id,
200+
SledPolicy::InService {
201+
provision_policy: SledProvisionPolicy::Provisionable,
202+
},
197203
sim_sled_agent_addr,
204+
REPO_DEPOT_PORT,
198205
SledRole::Scrimlet,
199206
),
200207
)]);

nexus/test-utils/src/lib.rs

+26
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,21 @@ impl RackInitRequestBuilder {
308308
.expect("Failed to set up DNS for {kind}");
309309
}
310310

311+
fn add_gz_service_to_dns(
312+
&mut self,
313+
sled_id: SledUuid,
314+
address: SocketAddrV6,
315+
service_name: ServiceName,
316+
) {
317+
let sled = self
318+
.internal_dns_config
319+
.host_sled(sled_id, *address.ip())
320+
.expect("Failed to set up DNS for GZ service");
321+
self.internal_dns_config
322+
.service_backend_sled(service_name, &sled, address.port())
323+
.expect("Failed to set up DNS for GZ service");
324+
}
325+
311326
// Special handling of ClickHouse, which has multiple SRV records for its
312327
// single zone.
313328
fn add_clickhouse_to_dns(
@@ -1036,6 +1051,17 @@ impl<'a, N: NexusServer> ControlPlaneTestContextBuilder<'a, N> {
10361051
.await
10371052
.expect("Failed to start sled agent");
10381053

1054+
// Add a DNS entry for the TUF Repo Depot on this simulated sled agent.
1055+
let SocketAddr::V6(server_addr_v6) = sled_agent.repo_depot_address
1056+
else {
1057+
panic!("expected sim sled agent to be listening on IPv6");
1058+
};
1059+
self.rack_init_builder.add_gz_service_to_dns(
1060+
sled_id,
1061+
server_addr_v6,
1062+
ServiceName::RepoDepot,
1063+
);
1064+
10391065
self.sled_agents.push(ControlPlaneTestContextSledAgent {
10401066
_storage: tempdir,
10411067
server: sled_agent,

nexus/types/src/deployment/execution/dns.rs

+22-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use omicron_uuid_kinds::SledUuid;
1313

1414
use crate::{
1515
deployment::{
16-
Blueprint, BlueprintZoneDisposition, BlueprintZoneType,
16+
Blueprint, BlueprintZoneDisposition, BlueprintZoneType, SledFilter,
1717
blueprint_zone_type,
1818
},
1919
internal_api::params::{DnsConfigZone, DnsRecord},
@@ -132,6 +132,27 @@ pub fn blueprint_internal_dns_config(
132132
)?;
133133
}
134134

135+
// For each sled to which we are supposed to be replicating artifacts,
136+
// define DNS entries for the repo depot service.
137+
//
138+
// Consumers need to be careful in using these names since artifacts are not
139+
// replicated synchronously or atomically to all instances. That is: a
140+
// consumer should be careful when fetching an artifact about whether they
141+
// really can just pick any backend of this service or not.
142+
for (sled_id, sled) in sleds_by_id {
143+
if !sled.policy().matches(SledFilter::TufArtifactReplication) {
144+
continue;
145+
}
146+
147+
let dns_sled =
148+
dns_builder.host_sled(*sled_id, *sled.sled_agent_address().ip())?;
149+
dns_builder.service_backend_sled(
150+
ServiceName::RepoDepot,
151+
&dns_sled,
152+
sled.repo_depot_address().port(),
153+
)?;
154+
}
155+
135156
Ok(dns_builder.build_zone())
136157
}
137158

nexus/types/src/deployment/execution/utils.rs

+24-3
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,57 @@ use nexus_sled_agent_shared::inventory::SledRole;
88
use omicron_common::address::{Ipv6Subnet, SLED_PREFIX};
99
use omicron_uuid_kinds::SledUuid;
1010

11-
use crate::deployment::{
12-
Blueprint, BlueprintZoneDisposition, BlueprintZoneType, blueprint_zone_type,
11+
use crate::{
12+
deployment::{
13+
Blueprint, BlueprintZoneDisposition, BlueprintZoneType,
14+
blueprint_zone_type,
15+
},
16+
external_api::views::SledPolicy,
1317
};
1418

1519
/// The minimal information needed to represent a sled in the context of
1620
/// blueprint execution.
1721
#[derive(Debug, Clone)]
1822
pub struct Sled {
1923
id: SledUuid,
24+
policy: SledPolicy,
2025
sled_agent_address: SocketAddrV6,
26+
repo_depot_port: u16,
2127
role: SledRole,
2228
}
2329

2430
impl Sled {
2531
pub fn new(
2632
id: SledUuid,
33+
policy: SledPolicy,
2734
sled_agent_address: SocketAddrV6,
35+
repo_depot_port: u16,
2836
role: SledRole,
2937
) -> Sled {
30-
Sled { id, sled_agent_address, role }
38+
Sled { id, policy, sled_agent_address, repo_depot_port, role }
3139
}
3240

3341
pub fn id(&self) -> SledUuid {
3442
self.id
3543
}
3644

45+
pub fn policy(&self) -> SledPolicy {
46+
self.policy
47+
}
48+
3749
pub fn sled_agent_address(&self) -> SocketAddrV6 {
3850
self.sled_agent_address
3951
}
4052

53+
pub fn repo_depot_address(&self) -> SocketAddrV6 {
54+
SocketAddrV6::new(
55+
*self.sled_agent_address().ip(),
56+
self.repo_depot_port,
57+
0,
58+
0,
59+
)
60+
}
61+
4162
pub fn subnet(&self) -> Ipv6Subnet<SLED_PREFIX> {
4263
Ipv6Subnet::<SLED_PREFIX>::new(*self.sled_agent_address.ip())
4364
}

sled-agent/src/rack_setup/plan/service.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use nexus_types::deployment::{
2222
};
2323
use omicron_common::address::{
2424
DENDRITE_PORT, DNS_HTTP_PORT, DNS_PORT, Ipv6Subnet, MGD_PORT, MGS_PORT,
25-
NEXUS_INTERNAL_PORT, NTP_PORT, NUM_SOURCE_NAT_PORTS,
25+
NEXUS_INTERNAL_PORT, NTP_PORT, NUM_SOURCE_NAT_PORTS, REPO_DEPOT_PORT,
2626
RSS_RESERVED_ADDRESSES, ReservedRackSubnet, SLED_PREFIX, get_sled_address,
2727
get_switch_zone_address,
2828
};
@@ -297,6 +297,20 @@ impl Plan {
297297
let mut dns_builder = DnsConfigBuilder::new();
298298
let mut svc_port_builder = ServicePortBuilder::new(config);
299299

300+
// All sleds get a DNS entry for Repo Depot.
301+
for sled in sled_info.iter() {
302+
let dns_sled = dns_builder
303+
.host_sled(sled.sled_id, *sled.sled_address.ip())
304+
.unwrap();
305+
dns_builder
306+
.service_backend_sled(
307+
ServiceName::RepoDepot,
308+
&dns_sled,
309+
REPO_DEPOT_PORT,
310+
)
311+
.unwrap();
312+
}
313+
300314
// Scrimlets get DNS records for running Dendrite.
301315
let scrimlets: Vec<_> =
302316
sled_info.iter().filter(|s| s.is_scrimlet).collect();

0 commit comments

Comments
 (0)