Skip to content

Commit 204b23f

Browse files
authored
[17/n] use IdOrdMap to index sleds in a few spots (#8400)
Was working in this area, thought it would be a nice cleanup. Depends on: * #8300
1 parent 1e85f94 commit 204b23f

File tree

21 files changed

+227
-187
lines changed

21 files changed

+227
-187
lines changed

Cargo.lock

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

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,7 +1730,7 @@ async fn get_crucible_dataset_rows(
17301730

17311731
let mut zpool_total_size: HashMap<Uuid, i64> = HashMap::new();
17321732

1733-
for (_, sled_agent) in latest_collection.sled_agents {
1733+
for sled_agent in latest_collection.sled_agents {
17341734
for zpool in sled_agent.zpools {
17351735
zpool_total_size
17361736
.insert(zpool.id.into_untyped_uuid(), zpool.total_size.into());
@@ -3855,7 +3855,7 @@ async fn cmd_db_dry_run_region_allocation(
38553855

38563856
let mut zpool_total_size: HashMap<Uuid, i64> = HashMap::new();
38573857

3858-
for (_, sled_agent) in latest_collection.sled_agents {
3858+
for sled_agent in latest_collection.sled_agents {
38593859
for zpool in sled_agent.zpools {
38603860
zpool_total_size
38613861
.insert(zpool.id.into_untyped_uuid(), zpool.total_size.into());
@@ -7275,7 +7275,7 @@ async fn inv_collection_print_devices(
72757275

72767276
fn inv_collection_print_sleds(collection: &Collection) {
72777277
println!("SLED AGENTS");
7278-
for sled in collection.sled_agents.values() {
7278+
for sled in &collection.sled_agents {
72797279
println!(
72807280
"\nsled {} (role = {:?}, serial {})",
72817281
sled.sled_id,
@@ -7436,7 +7436,7 @@ fn inv_collection_print_orphaned_datasets(collection: &Collection) {
74367436
LazyLock::new(IdOrdMap::new);
74377437

74387438
println!("ORPHANED DATASETS");
7439-
for sled in collection.sled_agents.values() {
7439+
for sled in &collection.sled_agents {
74407440
println!(
74417441
"\nsled {} (serial {})",
74427442
sled.sled_id,
@@ -8327,7 +8327,7 @@ async fn cmd_db_zpool_list(
83278327

83288328
let mut zpool_total_size: HashMap<Uuid, i64> = HashMap::new();
83298329

8330-
for (_, sled_agent) in latest_collection.sled_agents {
8330+
for sled_agent in latest_collection.sled_agents {
83318331
for zpool in sled_agent.zpools {
83328332
zpool_total_size
83338333
.insert(zpool.id.into_untyped_uuid(), zpool.total_size.into());

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3784,10 +3784,10 @@ async fn cmd_nexus_sled_expunge_disk_with_datastore(
37843784

37853785
let mut sleds_containing_disk = vec![];
37863786

3787-
for (sled_id, sled_agent) in collection.sled_agents {
3787+
for sled_agent in collection.sled_agents {
37883788
for sled_disk in sled_agent.disks {
37893789
if sled_disk.identity == disk_identity {
3790-
sleds_containing_disk.push(sled_id);
3790+
sleds_containing_disk.push(sled_agent.sled_id);
37913791
}
37923792
}
37933793
}

dev-tools/reconfigurator-cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ chrono.workspace = true
1818
clap.workspace = true
1919
colored.workspace = true
2020
humantime.workspace = true
21+
iddqd.workspace = true
2122
indent_write.workspace = true
2223
internal-dns-types.workspace = true
2324
itertools.workspace = true

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use anyhow::{Context, anyhow, bail};
88
use camino::Utf8PathBuf;
99
use clap::ValueEnum;
1010
use clap::{Args, Parser, Subcommand};
11+
use iddqd::IdOrdMap;
1112
use indent_write::fmt::IndentWriter;
1213
use internal_dns_types::diff::DnsDiff;
1314
use itertools::Itertools;
@@ -50,7 +51,6 @@ use omicron_uuid_kinds::SledUuid;
5051
use omicron_uuid_kinds::VnicUuid;
5152
use omicron_uuid_kinds::{BlueprintUuid, MupdateOverrideUuid};
5253
use std::borrow::Cow;
53-
use std::collections::BTreeMap;
5454
use std::fmt::{self, Write};
5555
use std::io::IsTerminal;
5656
use std::num::ParseIntError;
@@ -1454,27 +1454,27 @@ fn cmd_blueprint_diff(
14541454

14551455
fn make_sleds_by_id(
14561456
system: &SystemDescription,
1457-
) -> Result<BTreeMap<SledUuid, execution::Sled>, anyhow::Error> {
1457+
) -> Result<IdOrdMap<execution::Sled>, anyhow::Error> {
14581458
let collection = system
14591459
.to_collection_builder()
14601460
.context(
14611461
"unexpectedly failed to create collection for current set of sleds",
14621462
)?
14631463
.build();
1464-
let sleds_by_id: BTreeMap<_, _> = collection
1464+
let sleds_by_id: IdOrdMap<_> = collection
14651465
.sled_agents
14661466
.iter()
1467-
.map(|(sled_id, sled_agent_info)| {
1467+
.map(|sa| {
14681468
let sled = execution::Sled::new(
1469-
*sled_id,
1469+
sa.sled_id,
14701470
SledPolicy::InService {
14711471
provision_policy: SledProvisionPolicy::Provisionable,
14721472
},
1473-
sled_agent_info.sled_agent_address,
1473+
sa.sled_agent_address,
14741474
REPO_DEPOT_PORT,
1475-
sled_agent_info.sled_role,
1475+
sa.sled_role,
14761476
);
1477-
(*sled_id, sled)
1477+
sled
14781478
})
14791479
.collect();
14801480
Ok(sleds_by_id)

0 commit comments

Comments
 (0)