Skip to content

Commit c9fc674

Browse files
authored
[7/n] [reconfigurator] combine inventory and omicron zones (#6739)
Currently, when the collection process makes two separate queries to sled-agent: one to obtain basic inventory, and the other to obtain Omicron zones. With this approach, it is possible for one of the two queries to fail -- in that case, the `sled_agents` and `omicron_zones` maps will not have the same set of keys. In general, consumers of collections must be able to handle these kinds of failing cases, because collections contain information from a variety of sources, not all of which are guaranteed to work all the time. But this specific case (sled-agent inventory vs Omicron zones) is not intrinsic to the system -- it is an artifact of our APIs. Change the API so that the `/inventory` endpoint also returns Omicron zones. The format remains the same, so that `PUT /omicron-zones` mirrors `GET /inventory | jq .omicron_zones`. I had to make a few changes to our tests, since we now have a unified notion of Omicron zones and sled agents. But this exposed what feels to me like a modeling deficiency in the way our tests work. I hope to fix that up at some point soon. There is also one behavior change to the reconfigurator CLI -- now, `inventory-generate` preserves zone information passed into it from the system. This matches the behavior of inventory generation within tests themselves.
1 parent e634215 commit c9fc674

File tree

28 files changed

+339
-391
lines changed

28 files changed

+339
-391
lines changed

dev-tools/omdb/src/bin/omdb/db.rs

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5180,31 +5180,23 @@ fn inv_collection_print_sleds(collection: &Collection) {
51805180
println!(" reservation: {reservation:?}, quota: {quota:?}");
51815181
}
51825182

5183-
if let Some(zones) = collection.omicron_zones.get(&sled.sled_id) {
5184-
println!(
5185-
" zones collected from {} at {}",
5186-
zones.source, zones.time_collected,
5187-
);
5188-
println!(
5189-
" zones generation: {} (count: {})",
5190-
zones.zones.generation,
5191-
zones.zones.zones.len()
5192-
);
5183+
println!(
5184+
" zones generation: {} (count: {})",
5185+
sled.omicron_zones.generation,
5186+
sled.omicron_zones.zones.len(),
5187+
);
51935188

5194-
if zones.zones.zones.is_empty() {
5195-
continue;
5196-
}
5189+
if sled.omicron_zones.zones.is_empty() {
5190+
continue;
5191+
}
51975192

5198-
println!(" ZONES FOUND");
5199-
for z in &zones.zones.zones {
5200-
println!(
5201-
" zone {} (type {})",
5202-
z.id,
5203-
z.zone_type.kind().report_str()
5204-
);
5205-
}
5206-
} else {
5207-
println!(" warning: no zone information found");
5193+
println!(" ZONES FOUND");
5194+
for z in &sled.omicron_zones.zones {
5195+
println!(
5196+
" zone {} (type {})",
5197+
z.id,
5198+
z.zone_type.kind().report_str()
5199+
);
52085200
}
52095201
}
52105202
}

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

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use nexus_reconfigurator_planning::planner::Planner;
2121
use nexus_reconfigurator_planning::system::{
2222
SledBuilder, SledHwInventory, SystemDescription,
2323
};
24-
use nexus_sled_agent_shared::inventory::OmicronZonesConfig;
2524
use nexus_sled_agent_shared::inventory::ZoneKind;
2625
use nexus_types::deployment::execution;
2726
use nexus_types::deployment::execution::blueprint_external_dns_config;
@@ -739,25 +738,11 @@ fn cmd_inventory_list(
739738
fn cmd_inventory_generate(
740739
sim: &mut ReconfiguratorSim,
741740
) -> anyhow::Result<Option<String>> {
742-
let mut builder =
741+
let builder =
743742
sim.system.to_collection_builder().context("generating inventory")?;
744-
// For an inventory we just generated from thin air, pretend like each sled
745-
// has no zones on it.
746-
let planning_input =
747-
sim.system.to_planning_input_builder().unwrap().build();
748-
for sled_id in planning_input.all_sled_ids(SledFilter::Commissioned) {
749-
builder
750-
.found_sled_omicron_zones(
751-
"fake sled agent",
752-
sled_id,
753-
OmicronZonesConfig {
754-
generation: Generation::new(),
755-
zones: vec![],
756-
},
757-
)
758-
.context("recording Omicron zones")?;
759-
}
760743

744+
// sim.system carries around Omicron zones, which will make their way into
745+
// the inventory.
761746
let mut inventory = builder.build();
762747
// Assign collection IDs from the RNG. This enables consistent results when
763748
// callers have explicitly seeded the RNG (e.g., in tests).

dev-tools/reconfigurator-cli/tests/output/cmd-example-stdout

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ generated inventory collection b32394d8-7d79-486f-8657-fd5219508181 from configu
328328
> blueprint-diff-inventory b32394d8-7d79-486f-8657-fd5219508181 ade5749d-bdf3-4fab-a8ae-00bea01b3a5a
329329
from: collection b32394d8-7d79-486f-8657-fd5219508181
330330
to: blueprint ade5749d-bdf3-4fab-a8ae-00bea01b3a5a
331-
MODIFIED SLEDS:
331+
UNCHANGED SLEDS:
332332

333333
sled 2eb69596-f081-4e2d-9425-9994926e0832 (active):
334334

@@ -348,24 +348,24 @@ to: blueprint ade5749d-bdf3-4fab-a8ae-00bea01b3a5a
348348
fake-vendor fake-model serial-d792c8cb-7490-40cb-bb1c-d4917242edf4
349349

350350

351-
omicron zones generation 1 -> 2:
351+
omicron zones at generation 2:
352352
------------------------------------------------------------------------------------------
353353
zone type zone id disposition underlay IP
354354
------------------------------------------------------------------------------------------
355-
+ clickhouse fe79023f-c5d5-4be5-ad2c-da4e9e9237e4 in service fd00:1122:3344:102::23
356-
+ crucible 054f64a5-182c-4c28-8994-d2e082550201 in service fd00:1122:3344:102::26
357-
+ crucible 3b5bffea-e5ed-44df-8468-fd4fa69757d8 in service fd00:1122:3344:102::27
358-
+ crucible 53dd7fa4-899e-49ed-9fc2-48222db3e20d in service fd00:1122:3344:102::2a
359-
+ crucible 7db307d4-a6ed-4c47-bddf-6759161bf64a in service fd00:1122:3344:102::2c
360-
+ crucible 95ad9a1d-4063-4874-974c-2fc92830be27 in service fd00:1122:3344:102::29
361-
+ crucible bc095417-e2f0-4e95-b390-9cc3fc6e3c6d in service fd00:1122:3344:102::28
362-
+ crucible d90401f1-fbc2-42cb-bf17-309ee0f922fe in service fd00:1122:3344:102::2b
363-
+ crucible e8f994c0-0a1b-40e6-8db1-40a8ca89e503 in service fd00:1122:3344:102::2d
364-
+ crucible eaec16c0-0d44-4847-b2d6-31a5151bae52 in service fd00:1122:3344:102::24
365-
+ crucible f97aa057-6485-45d0-9cb4-4af5b0831d48 in service fd00:1122:3344:102::25
366-
+ internal_dns 8b8f7c02-7a18-4268-b045-2e286b464c5d in service fd00:1122:3344:1::1
367-
+ internal_ntp c67dd9a4-0d6c-4e9f-b28d-20003f211f7d in service fd00:1122:3344:102::21
368-
+ nexus 94b45ce9-d3d8-413a-a76b-865da1f67930 in service fd00:1122:3344:102::22
355+
clickhouse fe79023f-c5d5-4be5-ad2c-da4e9e9237e4 in service fd00:1122:3344:102::23
356+
crucible 054f64a5-182c-4c28-8994-d2e082550201 in service fd00:1122:3344:102::26
357+
crucible 3b5bffea-e5ed-44df-8468-fd4fa69757d8 in service fd00:1122:3344:102::27
358+
crucible 53dd7fa4-899e-49ed-9fc2-48222db3e20d in service fd00:1122:3344:102::2a
359+
crucible 7db307d4-a6ed-4c47-bddf-6759161bf64a in service fd00:1122:3344:102::2c
360+
crucible 95ad9a1d-4063-4874-974c-2fc92830be27 in service fd00:1122:3344:102::29
361+
crucible bc095417-e2f0-4e95-b390-9cc3fc6e3c6d in service fd00:1122:3344:102::28
362+
crucible d90401f1-fbc2-42cb-bf17-309ee0f922fe in service fd00:1122:3344:102::2b
363+
crucible e8f994c0-0a1b-40e6-8db1-40a8ca89e503 in service fd00:1122:3344:102::2d
364+
crucible eaec16c0-0d44-4847-b2d6-31a5151bae52 in service fd00:1122:3344:102::24
365+
crucible f97aa057-6485-45d0-9cb4-4af5b0831d48 in service fd00:1122:3344:102::25
366+
internal_dns 8b8f7c02-7a18-4268-b045-2e286b464c5d in service fd00:1122:3344:1::1
367+
internal_ntp c67dd9a4-0d6c-4e9f-b28d-20003f211f7d in service fd00:1122:3344:102::21
368+
nexus 94b45ce9-d3d8-413a-a76b-865da1f67930 in service fd00:1122:3344:102::22
369369

370370

371371
sled 32d8d836-4d8a-4e54-8fa9-f31d79c42646 (active):
@@ -386,23 +386,23 @@ to: blueprint ade5749d-bdf3-4fab-a8ae-00bea01b3a5a
386386
fake-vendor fake-model serial-d7410a1c-e01d-49a4-be9c-f861f086760a
387387

388388

389-
omicron zones generation 1 -> 2:
389+
omicron zones at generation 2:
390390
------------------------------------------------------------------------------------------
391391
zone type zone id disposition underlay IP
392392
------------------------------------------------------------------------------------------
393-
+ crucible 728db429-8621-4e1e-9915-282aadfa27d1 in service fd00:1122:3344:103::24
394-
+ crucible a999e5fa-3edc-4dac-919a-d7b554cdae58 in service fd00:1122:3344:103::27
395-
+ crucible b416f299-c23c-46c8-9820-be2b66ffea0a in service fd00:1122:3344:103::28
396-
+ crucible b5d5491d-b3aa-4727-8b55-f66e0581ea4f in service fd00:1122:3344:103::2c
397-
+ crucible cc1dc86d-bd6f-4929-aa4a-9619012e9393 in service fd00:1122:3344:103::25
398-
+ crucible cd3bb540-e605-465f-8c62-177ac482d850 in service fd00:1122:3344:103::2a
399-
+ crucible e7dd3e98-7fe7-4827-be7f-395ff9a5f542 in service fd00:1122:3344:103::23
400-
+ crucible e8971ab3-fb7d-4ad8-aae3-7f2fe87c51f3 in service fd00:1122:3344:103::26
401-
+ crucible f52aa245-7e1b-46c0-8a31-e09725f02caf in service fd00:1122:3344:103::2b
402-
+ crucible fae49024-6cec-444d-a6c4-83658ab015a4 in service fd00:1122:3344:103::29
403-
+ internal_dns c8aa84a5-a802-46c9-adcd-d61e9c8393c9 in service fd00:1122:3344:2::1
404-
+ internal_ntp e9bf481e-323e-466e-842f-8107078c7137 in service fd00:1122:3344:103::21
405-
+ nexus 4f2eb088-7d28-4c4e-a27c-746400ec65ba in service fd00:1122:3344:103::22
393+
crucible 728db429-8621-4e1e-9915-282aadfa27d1 in service fd00:1122:3344:103::24
394+
crucible a999e5fa-3edc-4dac-919a-d7b554cdae58 in service fd00:1122:3344:103::27
395+
crucible b416f299-c23c-46c8-9820-be2b66ffea0a in service fd00:1122:3344:103::28
396+
crucible b5d5491d-b3aa-4727-8b55-f66e0581ea4f in service fd00:1122:3344:103::2c
397+
crucible cc1dc86d-bd6f-4929-aa4a-9619012e9393 in service fd00:1122:3344:103::25
398+
crucible cd3bb540-e605-465f-8c62-177ac482d850 in service fd00:1122:3344:103::2a
399+
crucible e7dd3e98-7fe7-4827-be7f-395ff9a5f542 in service fd00:1122:3344:103::23
400+
crucible e8971ab3-fb7d-4ad8-aae3-7f2fe87c51f3 in service fd00:1122:3344:103::26
401+
crucible f52aa245-7e1b-46c0-8a31-e09725f02caf in service fd00:1122:3344:103::2b
402+
crucible fae49024-6cec-444d-a6c4-83658ab015a4 in service fd00:1122:3344:103::29
403+
internal_dns c8aa84a5-a802-46c9-adcd-d61e9c8393c9 in service fd00:1122:3344:2::1
404+
internal_ntp e9bf481e-323e-466e-842f-8107078c7137 in service fd00:1122:3344:103::21
405+
nexus 4f2eb088-7d28-4c4e-a27c-746400ec65ba in service fd00:1122:3344:103::22
406406

407407

408408
sled 89d02b1b-478c-401a-8e28-7a26f74fa41b (active):
@@ -423,23 +423,23 @@ to: blueprint ade5749d-bdf3-4fab-a8ae-00bea01b3a5a
423423
fake-vendor fake-model serial-fe1d5b9f-8db7-4e2d-bf17-c4b80e1f897c
424424

425425

426-
omicron zones generation 1 -> 2:
426+
omicron zones at generation 2:
427427
------------------------------------------------------------------------------------------
428428
zone type zone id disposition underlay IP
429429
------------------------------------------------------------------------------------------
430-
+ crucible 315a3670-d019-425c-b7a6-c9429428b671 in service fd00:1122:3344:101::25
431-
+ crucible 413d3e02-e19f-400a-9718-a662347538f0 in service fd00:1122:3344:101::26
432-
+ crucible 6cb330f9-4609-4d6c-98ad-b5cc34245813 in service fd00:1122:3344:101::2b
433-
+ crucible 6d725df0-0189-4429-b270-3eeb891d39c8 in service fd00:1122:3344:101::2a
434-
+ crucible 8b47e1e8-0396-4e44-a4a5-ea891405c9f2 in service fd00:1122:3344:101::24
435-
+ crucible b43ce109-90d6-46f9-9df0-8c68bfe6d4a0 in service fd00:1122:3344:101::23
436-
+ crucible b5443ebd-1f5b-448c-8edc-b4ca25c25db1 in service fd00:1122:3344:101::27
437-
+ crucible bb55534c-1042-4af4-ad2f-9590803695ac in service fd00:1122:3344:101::29
438-
+ crucible e135441d-637e-4de9-8023-5ea0096347f3 in service fd00:1122:3344:101::28
439-
+ crucible fee71ee6-da42-4a7f-a00e-f56b6a3327ce in service fd00:1122:3344:101::2c
440-
+ internal_dns cbe91cdc-cbb6-4760-aece-6ce08b67e85a in service fd00:1122:3344:3::1
441-
+ internal_ntp 09937ebb-bb6a-495b-bc97-b58076b70a78 in service fd00:1122:3344:101::21
442-
+ nexus f3628f0a-2301-4fc8-bcbf-961199771731 in service fd00:1122:3344:101::22
430+
crucible 315a3670-d019-425c-b7a6-c9429428b671 in service fd00:1122:3344:101::25
431+
crucible 413d3e02-e19f-400a-9718-a662347538f0 in service fd00:1122:3344:101::26
432+
crucible 6cb330f9-4609-4d6c-98ad-b5cc34245813 in service fd00:1122:3344:101::2b
433+
crucible 6d725df0-0189-4429-b270-3eeb891d39c8 in service fd00:1122:3344:101::2a
434+
crucible 8b47e1e8-0396-4e44-a4a5-ea891405c9f2 in service fd00:1122:3344:101::24
435+
crucible b43ce109-90d6-46f9-9df0-8c68bfe6d4a0 in service fd00:1122:3344:101::23
436+
crucible b5443ebd-1f5b-448c-8edc-b4ca25c25db1 in service fd00:1122:3344:101::27
437+
crucible bb55534c-1042-4af4-ad2f-9590803695ac in service fd00:1122:3344:101::29
438+
crucible e135441d-637e-4de9-8023-5ea0096347f3 in service fd00:1122:3344:101::28
439+
crucible fee71ee6-da42-4a7f-a00e-f56b6a3327ce in service fd00:1122:3344:101::2c
440+
internal_dns cbe91cdc-cbb6-4760-aece-6ce08b67e85a in service fd00:1122:3344:3::1
441+
internal_ntp 09937ebb-bb6a-495b-bc97-b58076b70a78 in service fd00:1122:3344:101::21
442+
nexus f3628f0a-2301-4fc8-bcbf-961199771731 in service fd00:1122:3344:101::22
443443

444444

445445
COCKROACHDB SETTINGS:

nexus-sled-agent-shared/src/inventory.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ pub struct Inventory {
9999
pub usable_hardware_threads: u32,
100100
pub usable_physical_ram: ByteCount,
101101
pub reservoir_size: ByteCount,
102+
pub omicron_zones: OmicronZonesConfig,
102103
pub disks: Vec<InventoryDisk>,
103104
pub zpools: Vec<InventoryZpool>,
104105
pub datasets: Vec<InventoryDataset>,

nexus/db-model/src/inventory.rs

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ use diesel::serialize::ToSql;
3131
use diesel::{serialize, sql_types};
3232
use ipnetwork::IpNetwork;
3333
use nexus_sled_agent_shared::inventory::OmicronZoneDataset;
34-
use nexus_sled_agent_shared::inventory::{
35-
OmicronZoneConfig, OmicronZoneType, OmicronZonesConfig,
36-
};
34+
use nexus_sled_agent_shared::inventory::{OmicronZoneConfig, OmicronZoneType};
3735
use nexus_types::inventory::{
3836
BaseboardId, Caboose, Collection, NvmeFirmware, PowerState, RotPage,
3937
RotSlot,
@@ -1178,7 +1176,11 @@ impl From<InvDataset> for nexus_types::inventory::Dataset {
11781176
}
11791177
}
11801178

1181-
/// See [`nexus_types::inventory::OmicronZonesFound`].
1179+
/// Information about a sled's Omicron zones, part of
1180+
/// [`nexus_types::inventory::SledAgent`].
1181+
///
1182+
/// TODO: This table is vestigial and can be combined with `InvSledAgent`. See
1183+
/// [issue #6770](https://github.com/oxidecomputer/omicron/issues/6770).
11821184
#[derive(Queryable, Clone, Debug, Selectable, Insertable)]
11831185
#[diesel(table_name = inv_sled_omicron_zones)]
11841186
pub struct InvSledOmicronZones {
@@ -1192,28 +1194,14 @@ pub struct InvSledOmicronZones {
11921194
impl InvSledOmicronZones {
11931195
pub fn new(
11941196
inv_collection_id: CollectionUuid,
1195-
zones_found: &nexus_types::inventory::OmicronZonesFound,
1197+
sled_agent: &nexus_types::inventory::SledAgent,
11961198
) -> InvSledOmicronZones {
11971199
InvSledOmicronZones {
11981200
inv_collection_id: inv_collection_id.into(),
1199-
time_collected: zones_found.time_collected,
1200-
source: zones_found.source.clone(),
1201-
sled_id: zones_found.sled_id.into(),
1202-
generation: Generation(zones_found.zones.generation),
1203-
}
1204-
}
1205-
1206-
pub fn into_uninit_zones_found(
1207-
self,
1208-
) -> nexus_types::inventory::OmicronZonesFound {
1209-
nexus_types::inventory::OmicronZonesFound {
1210-
time_collected: self.time_collected,
1211-
source: self.source,
1212-
sled_id: self.sled_id.into(),
1213-
zones: OmicronZonesConfig {
1214-
generation: *self.generation,
1215-
zones: Vec::new(),
1216-
},
1201+
time_collected: sled_agent.time_collected,
1202+
source: sled_agent.source.clone(),
1203+
sled_id: sled_agent.sled_id.into(),
1204+
generation: Generation(sled_agent.omicron_zones.generation),
12171205
}
12181206
}
12191207
}

nexus/db-queries/src/db/datastore/deployment.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,10 +1882,6 @@ mod tests {
18821882
&mut collection.sled_agents,
18831883
&mut base_collection.sled_agents,
18841884
);
1885-
mem::swap(
1886-
&mut collection.omicron_zones,
1887-
&mut base_collection.omicron_zones,
1888-
);
18891885

18901886
// Treat this blueprint as the initial blueprint for the system.
18911887
blueprint.parent_blueprint_id = None;
@@ -1999,7 +1995,7 @@ mod tests {
19991995
);
20001996
assert_eq!(
20011997
blueprint1.blueprint_zones.len(),
2002-
collection.omicron_zones.len()
1998+
collection.sled_agents.len()
20031999
);
20042000
assert_eq!(
20052001
blueprint1.all_omicron_zones(BlueprintZoneFilter::All).count(),

0 commit comments

Comments
 (0)