Skip to content

Commit cf57f89

Browse files
authored
internal/external DNS should only contain records for active Nexus instances (#9060)
1 parent 6419ef0 commit cf57f89

File tree

15 files changed

+445
-190
lines changed

15 files changed

+445
-190
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2443,14 +2443,26 @@ fn cmd_blueprint_diff(
24432443
// each blueprint. To do that we need to construct a list of sleds suitable
24442444
// for the executor.
24452445
let sleds_by_id = make_sleds_by_id(state.system().description())?;
2446+
2447+
// It's tricky to figure out which active Nexus generation number to use
2448+
// when diff'ing blueprints. What's currently active might be wholly
2449+
// different from what's here. (Imagine generation 7 is active and these
2450+
// blueprints are from Nexus generation 4.) What's most likely useful is
2451+
// picking the Nexus generation of the blueprint itself.
2452+
let blueprint1_active_nexus_generation =
2453+
blueprint_active_nexus_generation(&blueprint1);
2454+
let blueprint2_active_nexus_generation =
2455+
blueprint_active_nexus_generation(&blueprint2);
24462456
let internal_dns_config1 = blueprint_internal_dns_config(
24472457
&blueprint1,
24482458
&sleds_by_id,
2459+
blueprint1_active_nexus_generation,
24492460
&Default::default(),
24502461
)?;
24512462
let internal_dns_config2 = blueprint_internal_dns_config(
24522463
&blueprint2,
24532464
&sleds_by_id,
2465+
blueprint2_active_nexus_generation,
24542466
&Default::default(),
24552467
)?;
24562468
let dns_diff = DnsDiff::new(&internal_dns_config1, &internal_dns_config2)
@@ -2462,11 +2474,13 @@ fn cmd_blueprint_diff(
24622474
&blueprint1,
24632475
state.config().silo_names(),
24642476
external_dns_zone_name.to_owned(),
2477+
blueprint1_active_nexus_generation,
24652478
);
24662479
let external_dns_config2 = blueprint_external_dns_config(
24672480
&blueprint2,
24682481
state.config().silo_names(),
24692482
external_dns_zone_name.to_owned(),
2483+
blueprint2_active_nexus_generation,
24702484
);
24712485
let dns_diff = DnsDiff::new(&external_dns_config1, &external_dns_config2)
24722486
.context("failed to assemble external DNS diff")?;
@@ -2524,19 +2538,23 @@ fn cmd_blueprint_diff_dns(
25242538
}
25252539
};
25262540

2541+
let blueprint_active_generation =
2542+
blueprint_active_nexus_generation(&blueprint);
25272543
let blueprint_dns_zone = match dns_group {
25282544
CliDnsGroup::Internal => {
25292545
let sleds_by_id = make_sleds_by_id(state.system().description())?;
25302546
blueprint_internal_dns_config(
25312547
blueprint,
25322548
&sleds_by_id,
2549+
blueprint_active_generation,
25332550
&Default::default(),
25342551
)?
25352552
}
25362553
CliDnsGroup::External => blueprint_external_dns_config(
25372554
blueprint,
25382555
state.config().silo_names(),
25392556
state.config().external_dns_zone_name().to_owned(),
2557+
blueprint_active_generation,
25402558
),
25412559
};
25422560

@@ -3005,9 +3023,12 @@ fn cmd_load_example(
30053023

30063024
// Generate the internal and external DNS configs based on the blueprint.
30073025
let sleds_by_id = make_sleds_by_id(&example.system)?;
3026+
let blueprint_nexus_generation =
3027+
blueprint_active_nexus_generation(&blueprint);
30083028
let internal_dns = blueprint_internal_dns_config(
30093029
&blueprint,
30103030
&sleds_by_id,
3031+
blueprint_nexus_generation,
30113032
&Default::default(),
30123033
)?;
30133034
let external_dns_zone_name =
@@ -3016,6 +3037,7 @@ fn cmd_load_example(
30163037
&blueprint,
30173038
state.config_mut().silo_names(),
30183039
external_dns_zone_name,
3040+
blueprint_nexus_generation,
30193041
);
30203042

30213043
let blueprint_id = blueprint.id;
@@ -3082,3 +3104,30 @@ fn cmd_file_contents(args: FileContentsArgs) -> anyhow::Result<Option<String>> {
30823104

30833105
Ok(Some(s))
30843106
}
3107+
3108+
/// Returns the "active Nexus generation" to use for a historical blueprint
3109+
/// (i.e., a blueprint that may not have been generated or executed against the
3110+
/// current simulated state). This is used for `blueprint-diff`, for example,
3111+
/// which avoids assuming anything about the simulated state in comparing the
3112+
/// two blueprints.
3113+
///
3114+
/// In general, the active Nexus generation for a blueprint is not well-defined.
3115+
/// We cannot know what the active Nexus generation was at some point in the
3116+
/// past. But we do know that it's one of these two values:
3117+
///
3118+
/// - `blueprint.nexus_generation - 1`, if this blueprint was created as part
3119+
/// of an upgrade, starting with the point where the Nexus handoff was
3120+
/// initiated (inclusive) and ending with the first blueprint after the
3121+
/// handoff (exclusive). In most cases, this means that this is the single
3122+
/// blueprint during an upgrade that triggered the handoff.
3123+
/// - `blueprint.nexus_generation` otherwise (which includes all other
3124+
/// blueprints that are created during an upgrade and all blueprints created
3125+
/// outside of an upgrade).
3126+
///
3127+
/// This implementation always returns `blueprint.nexus_generation`. In the
3128+
/// second case above, this is always correct. In the first case, this is
3129+
/// basically equivalent to assuming that the Nexus handoff had happened
3130+
/// instantaneously when the blueprint was created.
3131+
fn blueprint_active_nexus_generation(blueprint: &Blueprint) -> Generation {
3132+
blueprint.nexus_generation
3133+
}

dev-tools/reconfigurator-cli/tests/input/cmds-target-release.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,9 @@ inventory-generate
459459

460460
# Planning now should bump the top-level `nexus_generation` to 2, indicating
461461
# that we want handoff to begin.
462+
# Note that `blueprint-diff` will show the DNS changes as though the handoff has
463+
# happened already because that command does not take into account simulated
464+
# state.
462465
blueprint-plan latest latest
463466
blueprint-diff latest
464467

dev-tools/reconfigurator-cli/tests/output/cmds-nexus-generation-stdout

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -117,38 +117,12 @@ to: blueprint 8da82a8e-bf97-4fbd-8ddd-9f6462732cf1
117117

118118

119119
internal DNS:
120-
* DNS zone: "control-plane.oxide.internal":
121-
+ name: 16a766ee-9400-4e67-9363-883670371a1b.host (records: 1)
122-
+ AAAA fd00:1122:3344:101::28
123-
* name: _nexus-lockstep._tcp (records: 3 -> 4)
124-
- SRV port 12232 0c71b3b2-6ceb-4e8f-b020-b08675e83038.host.control-plane.oxide.internal
125-
- SRV port 12232 3eeb8d49-eb1a-43f8-bb64-c2338421c2c6.host.control-plane.oxide.internal
126-
- SRV port 12232 466a9f29-62bf-4e63-924a-b9efdb86afec.host.control-plane.oxide.internal
127-
+ SRV port 12232 0c71b3b2-6ceb-4e8f-b020-b08675e83038.host.control-plane.oxide.internal
128-
+ SRV port 12232 16a766ee-9400-4e67-9363-883670371a1b.host.control-plane.oxide.internal
129-
+ SRV port 12232 3eeb8d49-eb1a-43f8-bb64-c2338421c2c6.host.control-plane.oxide.internal
130-
+ SRV port 12232 466a9f29-62bf-4e63-924a-b9efdb86afec.host.control-plane.oxide.internal
131-
* name: _nexus._tcp (records: 3 -> 4)
132-
- SRV port 12221 0c71b3b2-6ceb-4e8f-b020-b08675e83038.host.control-plane.oxide.internal
133-
- SRV port 12221 3eeb8d49-eb1a-43f8-bb64-c2338421c2c6.host.control-plane.oxide.internal
134-
- SRV port 12221 466a9f29-62bf-4e63-924a-b9efdb86afec.host.control-plane.oxide.internal
135-
+ SRV port 12221 0c71b3b2-6ceb-4e8f-b020-b08675e83038.host.control-plane.oxide.internal
136-
+ SRV port 12221 16a766ee-9400-4e67-9363-883670371a1b.host.control-plane.oxide.internal
137-
+ SRV port 12221 3eeb8d49-eb1a-43f8-bb64-c2338421c2c6.host.control-plane.oxide.internal
138-
+ SRV port 12221 466a9f29-62bf-4e63-924a-b9efdb86afec.host.control-plane.oxide.internal
139-
unchanged names: 50 (records: 62)
120+
DNS zone: "control-plane.oxide.internal" (unchanged)
121+
unchanged names: 52 (records: 68)
140122

141123
external DNS:
142-
* DNS zone: "oxide.example":
143-
* name: example-silo.sys (records: 3 -> 4)
144-
- A 192.0.2.2
145-
- A 192.0.2.3
146-
- A 192.0.2.4
147-
+ A 192.0.2.2
148-
+ A 192.0.2.3
149-
+ A 192.0.2.5
150-
+ A 192.0.2.4
151-
unchanged names: 4 (records: 6)
124+
DNS zone: "oxide.example" (unchanged)
125+
unchanged names: 5 (records: 9)
152126

153127

154128

@@ -177,12 +151,35 @@ to: blueprint 58d5e830-0884-47d8-a7cd-b2b3751adeb4
177151

178152

179153
internal DNS:
180-
DNS zone: "control-plane.oxide.internal" (unchanged)
181-
unchanged names: 53 (records: 71)
154+
* DNS zone: "control-plane.oxide.internal":
155+
- name: 0c71b3b2-6ceb-4e8f-b020-b08675e83038.host (records: 1)
156+
- AAAA fd00:1122:3344:101::22
157+
+ name: 16a766ee-9400-4e67-9363-883670371a1b.host (records: 1)
158+
+ AAAA fd00:1122:3344:101::28
159+
- name: 3eeb8d49-eb1a-43f8-bb64-c2338421c2c6.host (records: 1)
160+
- AAAA fd00:1122:3344:103::22
161+
- name: 466a9f29-62bf-4e63-924a-b9efdb86afec.host (records: 1)
162+
- AAAA fd00:1122:3344:102::22
163+
* name: _nexus-lockstep._tcp (records: 3 -> 1)
164+
- SRV port 12232 0c71b3b2-6ceb-4e8f-b020-b08675e83038.host.control-plane.oxide.internal
165+
- SRV port 12232 3eeb8d49-eb1a-43f8-bb64-c2338421c2c6.host.control-plane.oxide.internal
166+
- SRV port 12232 466a9f29-62bf-4e63-924a-b9efdb86afec.host.control-plane.oxide.internal
167+
+ SRV port 12232 16a766ee-9400-4e67-9363-883670371a1b.host.control-plane.oxide.internal
168+
* name: _nexus._tcp (records: 3 -> 1)
169+
- SRV port 12221 0c71b3b2-6ceb-4e8f-b020-b08675e83038.host.control-plane.oxide.internal
170+
- SRV port 12221 3eeb8d49-eb1a-43f8-bb64-c2338421c2c6.host.control-plane.oxide.internal
171+
- SRV port 12221 466a9f29-62bf-4e63-924a-b9efdb86afec.host.control-plane.oxide.internal
172+
+ SRV port 12221 16a766ee-9400-4e67-9363-883670371a1b.host.control-plane.oxide.internal
173+
unchanged names: 47 (records: 59)
182174

183175
external DNS:
184-
DNS zone: "oxide.example" (unchanged)
185-
unchanged names: 5 (records: 10)
176+
* DNS zone: "oxide.example":
177+
* name: example-silo.sys (records: 3 -> 1)
178+
- A 192.0.2.2
179+
- A 192.0.2.3
180+
- A 192.0.2.4
181+
+ A 192.0.2.5
182+
unchanged names: 4 (records: 6)
186183

187184

188185

0 commit comments

Comments
 (0)