Skip to content

Commit 00c53b7

Browse files
committed
Rename & change of type to BTreeSet
1 parent e7545fd commit 00c53b7

File tree

29 files changed

+170
-162
lines changed

29 files changed

+170
-162
lines changed

nexus/db-model/src/inventory.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ use sled_agent_types::inventory::ReconciledSingleMeasurement;
9292
use sled_agent_types::inventory::RemoveMupdateOverrideBootSuccessInventory;
9393
use sled_agent_types::inventory::RemoveMupdateOverrideInventory;
9494
use sled_agent_types::inventory::ZoneArtifactInventory;
95-
use sled_agent_types::inventory::ZoneImageResolverInventory;
95+
use sled_agent_types::inventory::OmicronFileSourceResolverInventory;
9696
use sled_agent_types::inventory::{
9797
ConfigReconcilerInventoryResult, OmicronSledConfig, OmicronZoneConfig,
9898
OmicronZoneDataset, OmicronZoneImageSource, OmicronZoneType,
@@ -920,7 +920,7 @@ pub struct InvSledAgent {
920920
pub reconciler_status: InvConfigReconcilerStatus,
921921

922922
#[diesel(embed)]
923-
pub zone_image_resolver: InvZoneImageResolver,
923+
pub file_source_resolver: InvOmicronFileSourceResolver,
924924
}
925925

926926
/// See [`sled_agent_types::inventory::ConfigReconcilerInventoryStatus`].
@@ -1290,7 +1290,7 @@ impl InvSledAgent {
12901290
sled_agent: &nexus_types::inventory::SledAgent,
12911291
ledgered_sled_config: Option<OmicronSledConfigUuid>,
12921292
reconciler_status: InvConfigReconcilerStatus,
1293-
zone_image_resolver: InvZoneImageResolver,
1293+
file_source_resolver: InvOmicronFileSourceResolver,
12941294
) -> Result<InvSledAgent, anyhow::Error> {
12951295
// It's irritating to have to check this case at runtime. The challenge
12961296
// is that if this sled agent does have a baseboard id, we don't know
@@ -1331,7 +1331,7 @@ impl InvSledAgent {
13311331
reservoir_size: ByteCount::from(sled_agent.reservoir_size),
13321332
ledgered_sled_config: ledgered_sled_config.map(From::from),
13331333
reconciler_status,
1334-
zone_image_resolver,
1334+
file_source_resolver,
13351335
})
13361336
}
13371337
}
@@ -1593,7 +1593,7 @@ impl_enum_type!(
15931593
/// Rows corresponding to the zone image resolver in `inv_sled_agent`.
15941594
#[derive(Queryable, Clone, Debug, Selectable, Insertable)]
15951595
#[diesel(table_name = inv_sled_agent)]
1596-
pub struct InvZoneImageResolver {
1596+
pub struct InvOmicronFileSourceResolver {
15971597
pub zone_manifest_boot_disk_path: String,
15981598
pub zone_manifest_source: Option<InvZoneManifestSourceEnum>,
15991599
pub zone_manifest_mupdate_id: Option<DbTypedUuid<MupdateKind>>,
@@ -1609,9 +1609,9 @@ pub struct InvZoneImageResolver {
16091609
pub mupdate_override_boot_disk_error: Option<String>,
16101610
}
16111611

1612-
impl InvZoneImageResolver {
1613-
/// Construct a new `InvZoneImageResolver`.
1614-
pub fn new(inv: &ZoneImageResolverInventory) -> Self {
1612+
impl InvOmicronFileSourceResolver {
1613+
/// Construct a new `InvOmicronFileSourceResolver`.
1614+
pub fn new(inv: &OmicronFileSourceResolverInventory) -> Self {
16151615
let zone_manifest_boot_disk_path =
16161616
inv.zone_manifest.boot_disk_path.clone().into();
16171617
let (
@@ -1692,7 +1692,7 @@ impl InvZoneImageResolver {
16921692
mupdate_override_non_boot: Option<
16931693
IdOrdMap<MupdateOverrideNonBootInventory>,
16941694
>,
1695-
) -> anyhow::Result<ZoneImageResolverInventory> {
1695+
) -> anyhow::Result<OmicronFileSourceResolverInventory> {
16961696
// Build up the ManifestInventory struct.
16971697
let zone_manifest = {
16981698
let boot_inventory = if let Some(error) =
@@ -1810,7 +1810,7 @@ impl InvZoneImageResolver {
18101810
non_boot_status: mupdate_override_non_boot.unwrap_or_default(),
18111811
};
18121812

1813-
Ok(ZoneImageResolverInventory {
1813+
Ok(OmicronFileSourceResolverInventory {
18141814
zone_manifest,
18151815
measurement_manifest,
18161816
mupdate_override,
@@ -2373,7 +2373,7 @@ impl InvOmicronSledConfig {
23732373
generation: external::Generation,
23742374
remove_mupdate_override: Option<MupdateOverrideUuid>,
23752375
host_phase_2: HostPhase2DesiredSlots,
2376-
measurements: Vec<OmicronSingleMeasurement>,
2376+
measurements: BTreeSet<OmicronSingleMeasurement>,
23772377
) -> Self {
23782378
Self {
23792379
inv_collection_id: inv_collection_id.into(),
@@ -2392,18 +2392,18 @@ pub struct DbOmicronMeasurements {
23922392
pub measurements: Option<Vec<ArtifactHash>>,
23932393
}
23942394

2395-
impl From<Vec<OmicronSingleMeasurement>> for DbOmicronMeasurements {
2396-
fn from(value: Vec<OmicronSingleMeasurement>) -> Self {
2395+
impl From<BTreeSet<OmicronSingleMeasurement>> for DbOmicronMeasurements {
2396+
fn from(value: BTreeSet<OmicronSingleMeasurement>) -> Self {
23972397
let remapped =
23982398
value.into_iter().map(|x| ArtifactHash(x.hash)).collect();
23992399
Self { measurements: Some(remapped) }
24002400
}
24012401
}
24022402

2403-
impl From<DbOmicronMeasurements> for Vec<OmicronSingleMeasurement> {
2403+
impl From<DbOmicronMeasurements> for BTreeSet<OmicronSingleMeasurement> {
24042404
fn from(value: DbOmicronMeasurements) -> Self {
24052405
match value.measurements {
2406-
None => Vec::new(),
2406+
None => BTreeSet::new(),
24072407
Some(s) => s
24082408
.into_iter()
24092409
.map(|ArtifactHash(hash)| OmicronSingleMeasurement { hash })

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

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ use nexus_db_model::SwCaboose;
7272
use nexus_db_model::SwRotPage;
7373
use nexus_db_model::to_db_typed_uuid;
7474
use nexus_db_model::{
75-
HwBaseboardId, InvZoneImageResolver, InvZoneManifestMeasurement,
75+
HwBaseboardId, InvOmicronFileSourceResolver, InvZoneManifestMeasurement,
7676
InvZoneManifestZone,
7777
};
7878
use nexus_db_model::{HwPowerState, InvZoneManifestNonBoot};
@@ -251,7 +251,7 @@ impl DataStore {
251251
let mut zone_manifest_zones = Vec::new();
252252
for sled_agent in &collection.sled_agents {
253253
if let Some(artifacts) = sled_agent
254-
.zone_image_resolver
254+
.file_source_resolver
255255
.zone_manifest
256256
.boot_inventory
257257
.as_ref()
@@ -276,7 +276,7 @@ impl DataStore {
276276
.iter()
277277
.filter_map(|sled_agent| {
278278
sled_agent
279-
.zone_image_resolver
279+
.file_source_resolver
280280
.measurement_manifest
281281
.boot_inventory
282282
.as_ref()
@@ -300,7 +300,7 @@ impl DataStore {
300300
.iter()
301301
.flat_map(|sled_agent| {
302302
sled_agent
303-
.zone_image_resolver
303+
.file_source_resolver
304304
.zone_manifest
305305
.non_boot_status
306306
.iter()
@@ -320,7 +320,7 @@ impl DataStore {
320320
.iter()
321321
.flat_map(|sled_agent| {
322322
sled_agent
323-
.zone_image_resolver
323+
.file_source_resolver
324324
.measurement_manifest
325325
.non_boot_status
326326
.iter()
@@ -340,7 +340,7 @@ impl DataStore {
340340
.iter()
341341
.flat_map(|sled_agent| {
342342
sled_agent
343-
.zone_image_resolver
343+
.file_source_resolver
344344
.mupdate_override
345345
.non_boot_status
346346
.iter()
@@ -409,14 +409,14 @@ impl DataStore {
409409
} = config_reconciler_fields_by_sled
410410
.remove(&sled_agent.sled_id)
411411
.expect("all sled IDs should exist");
412-
let zone_image_resolver =
413-
InvZoneImageResolver::new(&sled_agent.zone_image_resolver);
412+
let file_source_resolver =
413+
InvOmicronFileSourceResolver::new(&sled_agent.file_source_resolver);
414414
InvSledAgent::new_without_baseboard(
415415
collection_id,
416416
sled_agent,
417417
ledgered_sled_config,
418418
reconciler_status,
419-
zone_image_resolver,
419+
file_source_resolver,
420420
)
421421
.map_err(|e| Error::internal_error(&e.to_string()))
422422
})
@@ -1526,7 +1526,7 @@ impl DataStore {
15261526
} = config_reconciler_fields_by_sled
15271527
.remove(&sled_agent.sled_id)
15281528
.expect("all sled IDs should exist");
1529-
let zone_image_resolver = InvZoneImageResolver::new(&sled_agent.zone_image_resolver);
1529+
let file_source_resolver = InvOmicronFileSourceResolver::new(&sled_agent.file_source_resolver);
15301530
let selection = nexus_db_schema::schema::hw_baseboard_id::table
15311531
.select((
15321532
db_collection_id
@@ -1573,27 +1573,27 @@ impl DataStore {
15731573
.into_sql::<Nullable<diesel::sql_types::Timestamptz>>(),
15741574
reconciler_status.reconciler_status_duration_secs
15751575
.into_sql::<Nullable<diesel::sql_types::Double>>(),
1576-
zone_image_resolver.zone_manifest_boot_disk_path
1576+
file_source_resolver.zone_manifest_boot_disk_path
15771577
.into_sql::<diesel::sql_types::Text>(),
1578-
zone_image_resolver.zone_manifest_source
1578+
file_source_resolver.zone_manifest_source
15791579
.into_sql::<Nullable<InvZoneManifestSourceEnum>>(),
1580-
zone_image_resolver.zone_manifest_mupdate_id
1580+
file_source_resolver.zone_manifest_mupdate_id
15811581
.into_sql::<Nullable<diesel::sql_types::Uuid>>(),
1582-
zone_image_resolver.zone_manifest_boot_disk_error
1582+
file_source_resolver.zone_manifest_boot_disk_error
15831583
.into_sql::<Nullable<diesel::sql_types::Text>>(),
1584-
zone_image_resolver.measurement_manifest_boot_disk_path
1584+
file_source_resolver.measurement_manifest_boot_disk_path
15851585
.into_sql::<diesel::sql_types::Text>(),
1586-
zone_image_resolver.measurement_manifest_source
1586+
file_source_resolver.measurement_manifest_source
15871587
.into_sql::<Nullable<InvZoneManifestSourceEnum>>(),
1588-
zone_image_resolver.measurement_manifest_mupdate_id
1588+
file_source_resolver.measurement_manifest_mupdate_id
15891589
.into_sql::<Nullable<diesel::sql_types::Uuid>>(),
1590-
zone_image_resolver.measurement_manifest_boot_disk_error
1590+
file_source_resolver.measurement_manifest_boot_disk_error
15911591
.into_sql::<Nullable<diesel::sql_types::Text>>(),
1592-
zone_image_resolver.mupdate_override_boot_disk_path
1592+
file_source_resolver.mupdate_override_boot_disk_path
15931593
.into_sql::<diesel::sql_types::Text>(),
1594-
zone_image_resolver.mupdate_override_id
1594+
file_source_resolver.mupdate_override_id
15951595
.into_sql::<Nullable<diesel::sql_types::Uuid>>(),
1596-
zone_image_resolver.mupdate_override_boot_disk_error
1596+
file_source_resolver.mupdate_override_boot_disk_error
15971597
.into_sql::<Nullable<diesel::sql_types::Text>>(),
15981598
))
15991599
.filter(
@@ -4249,8 +4249,8 @@ impl DataStore {
42494249
})
42504250
.transpose()?;
42514251

4252-
let zone_image_resolver = s
4253-
.zone_image_resolver
4252+
let file_source_resolver = s
4253+
.file_source_resolver
42544254
.into_inventory(
42554255
zone_manifest_artifacts_by_sled_id.remove(&sled_id),
42564256
measurement_manifest_artifacts_by_sled_id.remove(&sled_id),
@@ -4301,7 +4301,7 @@ impl DataStore {
43014301
ledgered_sled_config,
43024302
reconciler_status,
43034303
last_reconciliation,
4304-
zone_image_resolver,
4304+
file_source_resolver,
43054305
// TODO-K[omicron#9516]: Actually query the DB when there is
43064306
// something there
43074307
health_monitor: HealthMonitorInventory::new(),

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ mod test {
348348
use sled_agent_types::inventory::{
349349
Baseboard, ConfigReconcilerInventoryStatus, HealthMonitorInventory,
350350
Inventory, InventoryDisk, SledCpuFamily, SledRole,
351-
ZoneImageResolverInventory,
351+
OmicronFileSourceResolverInventory,
352352
};
353353
use std::num::NonZeroU32;
354354

@@ -705,7 +705,7 @@ mod test {
705705
reconciler_status:
706706
ConfigReconcilerInventoryStatus::NotYetRun,
707707
last_reconciliation: None,
708-
zone_image_resolver: ZoneImageResolverInventory::new_fake(),
708+
file_source_resolver: OmicronFileSourceResolverInventory::new_fake(),
709709
health_monitor: HealthMonitorInventory::new(),
710710
},
711711
)

nexus/inventory/src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ impl CollectionBuilder {
674674
ledgered_sled_config: inventory.ledgered_sled_config,
675675
reconciler_status: inventory.reconciler_status,
676676
last_reconciliation: inventory.last_reconciliation,
677-
zone_image_resolver: inventory.zone_image_resolver,
677+
file_source_resolver: inventory.file_source_resolver,
678678
health_monitor: inventory.health_monitor,
679679
};
680680

nexus/inventory/src/collector.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use std::time::Duration;
3333
use strum::IntoEnumIterator;
3434
use tufaceous_artifact::ArtifactHash;
3535

36+
3637
/// connection and request timeout used for Sled Agent HTTP client
3738
const SLED_AGENT_TIMEOUT: Duration = Duration::from_secs(60);
3839

@@ -744,6 +745,7 @@ mod test {
744745
use swrite::SWrite as _;
745746
use swrite::swrite;
746747
use swrite::swriteln;
748+
use std::collections::BTreeSet;
747749

748750
fn dump_sled_config(s: &mut String, config: &OmicronSledConfig) {
749751
let OmicronSledConfig {
@@ -1013,7 +1015,7 @@ mod test {
10131015
},
10141016
remove_mupdate_override: None,
10151017
host_phase_2: HostPhase2DesiredSlots::current_contents(),
1016-
measurements: Vec::new(),
1018+
measurements: BTreeSet::new(),
10171019
})
10181020
.await
10191021
.expect("failed to write initial zone version to fake sled agent");

0 commit comments

Comments
 (0)