Skip to content

[17/n] use IdOrdMap to index sleds in a few spots #8400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions dev-tools/omdb/src/bin/omdb/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1730,7 +1730,7 @@ async fn get_crucible_dataset_rows(

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

for (_, sled_agent) in latest_collection.sled_agents {
for sled_agent in latest_collection.sled_agents {
for zpool in sled_agent.zpools {
zpool_total_size
.insert(zpool.id.into_untyped_uuid(), zpool.total_size.into());
Expand Down Expand Up @@ -3855,7 +3855,7 @@ async fn cmd_db_dry_run_region_allocation(

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

for (_, sled_agent) in latest_collection.sled_agents {
for sled_agent in latest_collection.sled_agents {
for zpool in sled_agent.zpools {
zpool_total_size
.insert(zpool.id.into_untyped_uuid(), zpool.total_size.into());
Expand Down Expand Up @@ -7275,7 +7275,7 @@ async fn inv_collection_print_devices(

fn inv_collection_print_sleds(collection: &Collection) {
println!("SLED AGENTS");
for sled in collection.sled_agents.values() {
for sled in &collection.sled_agents {
println!(
"\nsled {} (role = {:?}, serial {})",
sled.sled_id,
Expand Down Expand Up @@ -7436,7 +7436,7 @@ fn inv_collection_print_orphaned_datasets(collection: &Collection) {
LazyLock::new(IdOrdMap::new);

println!("ORPHANED DATASETS");
for sled in collection.sled_agents.values() {
for sled in &collection.sled_agents {
println!(
"\nsled {} (serial {})",
sled.sled_id,
Expand Down Expand Up @@ -8327,7 +8327,7 @@ async fn cmd_db_zpool_list(

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

for (_, sled_agent) in latest_collection.sled_agents {
for sled_agent in latest_collection.sled_agents {
for zpool in sled_agent.zpools {
zpool_total_size
.insert(zpool.id.into_untyped_uuid(), zpool.total_size.into());
Expand Down
4 changes: 2 additions & 2 deletions dev-tools/omdb/src/bin/omdb/nexus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3784,10 +3784,10 @@ async fn cmd_nexus_sled_expunge_disk_with_datastore(

let mut sleds_containing_disk = vec![];

for (sled_id, sled_agent) in collection.sled_agents {
for sled_agent in collection.sled_agents {
for sled_disk in sled_agent.disks {
if sled_disk.identity == disk_identity {
sleds_containing_disk.push(sled_id);
sleds_containing_disk.push(sled_agent.sled_id);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions dev-tools/reconfigurator-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ chrono.workspace = true
clap.workspace = true
colored.workspace = true
humantime.workspace = true
iddqd.workspace = true
indent_write.workspace = true
internal-dns-types.workspace = true
itertools.workspace = true
Expand Down
16 changes: 8 additions & 8 deletions dev-tools/reconfigurator-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use anyhow::{Context, anyhow, bail};
use camino::Utf8PathBuf;
use clap::ValueEnum;
use clap::{Args, Parser, Subcommand};
use iddqd::IdOrdMap;
use indent_write::fmt::IndentWriter;
use internal_dns_types::diff::DnsDiff;
use itertools::Itertools;
Expand Down Expand Up @@ -50,7 +51,6 @@ use omicron_uuid_kinds::SledUuid;
use omicron_uuid_kinds::VnicUuid;
use omicron_uuid_kinds::{BlueprintUuid, MupdateOverrideUuid};
use std::borrow::Cow;
use std::collections::BTreeMap;
use std::fmt::{self, Write};
use std::io::IsTerminal;
use std::num::ParseIntError;
Expand Down Expand Up @@ -1454,27 +1454,27 @@ fn cmd_blueprint_diff(

fn make_sleds_by_id(
system: &SystemDescription,
) -> Result<BTreeMap<SledUuid, execution::Sled>, anyhow::Error> {
) -> Result<IdOrdMap<execution::Sled>, anyhow::Error> {
let collection = system
.to_collection_builder()
.context(
"unexpectedly failed to create collection for current set of sleds",
)?
.build();
let sleds_by_id: BTreeMap<_, _> = collection
let sleds_by_id: IdOrdMap<_> = collection
.sled_agents
.iter()
.map(|(sled_id, sled_agent_info)| {
.map(|sa| {
let sled = execution::Sled::new(
*sled_id,
sa.sled_id,
SledPolicy::InService {
provision_policy: SledProvisionPolicy::Provisionable,
},
sled_agent_info.sled_agent_address,
sa.sled_agent_address,
REPO_DEPOT_PORT,
sled_agent_info.sled_role,
sa.sled_role,
);
(*sled_id, sled)
sled
})
.collect();
Ok(sleds_by_id)
Expand Down
Loading
Loading