Skip to content

Commit

Permalink
Merge branch 'affinity-db-crud' into affinity-instance-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
smklein committed Feb 19, 2025
2 parents 10aaed9 + ee657cc commit 931801d
Show file tree
Hide file tree
Showing 15 changed files with 324 additions and 100 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ nexus-test-interface = { path = "nexus/test-interface" }
nexus-test-utils-macros = { path = "nexus/test-utils-macros" }
nexus-test-utils = { path = "nexus/test-utils" }
nexus-types = { path = "nexus/types" }
nix = { version = "0.29", features = ["net"] }
nom = "7.1.3"
num-integer = "0.1.46"
num = { version = "0.4.3", default-features = false, features = [ "libm" ] }
Expand Down
140 changes: 111 additions & 29 deletions dev-tools/omdb/src/bin/omdb/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ async fn cmd_db_disk_info(
struct DownstairsRow {
host_serial: String,
region: String,
zone: String,
dataset: String,
physical_disk: String,
}

Expand Down Expand Up @@ -1688,7 +1688,7 @@ async fn cmd_db_disk_info(
rows.push(DownstairsRow {
host_serial: my_sled.serial_number().to_string(),
region: region.id().to_string(),
zone: format!("oxz_crucible_{}", dataset.id()),
dataset: dataset.id().to_string(),
physical_disk: my_zpool.physical_disk_id.to_string(),
});
}
Expand Down Expand Up @@ -1724,7 +1724,7 @@ async fn get_and_display_vcr(
for v in volumes {
match serde_json::from_str(&v.data()) {
Ok(vcr) => {
println!("\nVCR from volume ID {volume_id}");
println!("VCR from volume ID {volume_id}");
print_vcr(vcr, 0);
}
Err(e) => {
Expand Down Expand Up @@ -2125,45 +2125,88 @@ async fn cmd_db_snapshot_info(
struct DownstairsRow {
host_serial: String,
region: String,
zone: String,
dataset: String,
physical_disk: String,
}

use db::schema::snapshot::dsl as snapshot_dsl;
let snapshots = snapshot_dsl::snapshot
let mut snapshots = snapshot_dsl::snapshot
.filter(snapshot_dsl::id.eq(args.uuid))
.limit(1)
.select(Snapshot::as_select())
.load_async(&*datastore.pool_connection_for_tests().await?)
.await
.context("loading requested snapshot")?;

let mut dest_volume_ids = Vec::new();
let mut source_volume_ids = Vec::new();
let rows = snapshots.into_iter().map(|snapshot| {
dest_volume_ids.push(snapshot.destination_volume_id());
source_volume_ids.push(snapshot.volume_id());
SnapshotRow::from(snapshot)
});
if rows.len() == 0 {
bail!("No snapshout with UUID: {} found", args.uuid);
if snapshots.is_empty() {
bail!("No snapshot with UUID: {} found", args.uuid);
}
let snap = snapshots.pop().expect("Found more that one snapshot");

let table = tabled::Table::new(rows)
.with(tabled::settings::Style::empty())
.with(tabled::settings::Padding::new(0, 1, 0, 0))
.to_string();
let dest_vol_id = snap.destination_volume_id;
let source_vol_id = snap.volume_id;
let snap = SnapshotRow::from(snap);

println!("{}", table);
println!(" Name: {}", snap.snap_name);
println!(" id: {}", snap.id);
println!(" state: {}", snap.state);
println!(" size: {}", snap.size);
println!(" source_disk_id: {}", snap.source_disk_id);
println!(" source_volume_id: {}", snap.source_volume_id);
println!("destination_volume_id: {}", snap.destination_volume_id);

println!("SOURCE VOLUME VCR:");
for vol in source_volume_ids {
get_and_display_vcr(vol, datastore).await?;
use db::schema::region_snapshot::dsl as region_snapshot_dsl;
let region_snapshots = region_snapshot_dsl::region_snapshot
.filter(region_snapshot_dsl::snapshot_id.eq(args.uuid))
.select(RegionSnapshot::as_select())
.load_async(&*datastore.pool_connection_for_tests().await?)
.await
.context("loading region snapshots")?;

println!();
if region_snapshots.is_empty() {
println!("No region snapshot info found");
} else {
// The row describing the region_snapshot.
#[derive(Tabled)]
#[tabled(rename_all = "SCREAMING_SNAKE_CASE")]
struct RegionSnapshotRow {
dataset_id: String,
region_id: String,
snapshot_id: String,
snapshot_addr: String,
volume_references: String,
}
let mut rsnap = Vec::new();

// From each region snapshot:
// Collect the snapshot IDs for later use.
// Display the region snapshot rows.
let mut snapshot_ids = HashSet::new();
for rs in region_snapshots {
snapshot_ids.insert(rs.snapshot_id);
let rs = RegionSnapshotRow {
dataset_id: rs.dataset_id.to_string(),
region_id: rs.region_id.to_string(),
snapshot_id: rs.snapshot_id.to_string(),
snapshot_addr: rs.snapshot_addr.to_string(),
volume_references: rs.volume_references.to_string(),
};
rsnap.push(rs);
}
let table = tabled::Table::new(rsnap)
.with(tabled::settings::Style::empty())
.with(tabled::settings::Padding::new(0, 1, 0, 0))
.to_string();

println!("REGION SNAPSHOT INFO:");
println!("{}", table);
}
for vol_id in dest_volume_ids {
// Get the dataset backing this volume.
let regions = datastore.get_allocated_regions(vol_id).await?;

let regions = datastore.get_allocated_regions(source_vol_id.into()).await?;
if regions.is_empty() {
println!("\nNo source region info found");
} else {
let mut rows = Vec::with_capacity(3);
for (dataset, region) in regions {
let my_pool_id = dataset.pool_id;
Expand All @@ -2184,7 +2227,7 @@ async fn cmd_db_snapshot_info(
rows.push(DownstairsRow {
host_serial: my_sled.serial_number().to_string(),
region: region.id().to_string(),
zone: format!("oxz_crucible_{}", dataset.id()),
dataset: dataset.id().to_string(),
physical_disk: my_zpool.physical_disk_id.to_string(),
});
}
Expand All @@ -2194,12 +2237,51 @@ async fn cmd_db_snapshot_info(
.with(tabled::settings::Padding::new(0, 1, 0, 0))
.to_string();

println!("DESTINATION REGION INFO:");
println!("\nSOURCE REGION INFO:");
println!("{}", table);
println!("DESTINATION VOLUME VCR:");
get_and_display_vcr(vol_id, datastore).await?;
}

println!("SOURCE VOLUME VCR:");
get_and_display_vcr(source_vol_id.into(), datastore).await?;

// Get the dataset backing this volume.
let regions = datastore.get_allocated_regions(dest_vol_id.into()).await?;

let mut rows = Vec::with_capacity(3);
for (dataset, region) in regions {
let my_pool_id = dataset.pool_id;
let (_, my_zpool) = LookupPath::new(opctx, datastore)
.zpool_id(my_pool_id)
.fetch()
.await
.context("failed to look up zpool")?;

let my_sled_id = my_zpool.sled_id;

let (_, my_sled) = LookupPath::new(opctx, datastore)
.sled_id(my_sled_id)
.fetch()
.await
.context("failed to look up sled")?;

rows.push(DownstairsRow {
host_serial: my_sled.serial_number().to_string(),
region: region.id().to_string(),
dataset: dataset.id().to_string(),
physical_disk: my_zpool.physical_disk_id.to_string(),
});
}

let table = tabled::Table::new(rows)
.with(tabled::settings::Style::empty())
.with(tabled::settings::Padding::new(0, 1, 0, 0))
.to_string();

println!("DESTINATION REGION INFO:");
println!("{}", table);
println!("DESTINATION VOLUME VCR:");
get_and_display_vcr(dest_vol_id.into(), datastore).await?;

Ok(())
}

Expand Down
40 changes: 32 additions & 8 deletions gateway-test-utils/configs/sp_sim_config.test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@
# concurrently.
#
[[simulated_sps.sidecar]]
multicast_addr = "::1"
bind_addrs = ["[::1]:0", "[::1]:0"]
serial_number = "SimSidecar0"
manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de"
device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000000"

[[simulated_sps.sidecar.network_config]]
[simulated_sps.sidecar.network_config.simulated]
bind_addr = "[::1]:0"

[[simulated_sps.sidecar.network_config]]
[simulated_sps.sidecar.network_config.simulated]
bind_addr = "[::1]:0"

[[simulated_sps.sidecar.components]]
id = "dev-0"
device = "fake-tmp-sensor"
Expand All @@ -35,19 +41,31 @@ sensors = [
]

[[simulated_sps.sidecar]]
multicast_addr = "::1"
bind_addrs = ["[::1]:0", "[::1]:0"]
serial_number = "SimSidecar1"
manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de"
device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000001"

[[simulated_sps.sidecar.network_config]]
[simulated_sps.sidecar.network_config.simulated]
bind_addr = "[::1]:0"

[[simulated_sps.sidecar.network_config]]
[simulated_sps.sidecar.network_config.simulated]
bind_addr = "[::1]:0"

[[simulated_sps.gimlet]]
multicast_addr = "::1"
bind_addrs = ["[::1]:0", "[::1]:0"]
serial_number = "SimGimlet00"
manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de"
device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000002"

[[simulated_sps.gimlet.network_config]]
[simulated_sps.gimlet.network_config.simulated]
bind_addr = "[::1]:0"

[[simulated_sps.gimlet.network_config]]
[simulated_sps.gimlet.network_config.simulated]
bind_addr = "[::1]:0"

[[simulated_sps.gimlet.components]]
id = "sp3-host-cpu"
device = "sp3-host-cpu"
Expand Down Expand Up @@ -151,12 +169,18 @@ sensors = [


[[simulated_sps.gimlet]]
multicast_addr = "::1"
bind_addrs = ["[::1]:0", "[::1]:0"]
serial_number = "SimGimlet01"
manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de"
device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000003"

[[simulated_sps.gimlet.network_config]]
[simulated_sps.gimlet.network_config.simulated]
bind_addr = "[::1]:0"

[[simulated_sps.gimlet.network_config]]
[simulated_sps.gimlet.network_config.simulated]
bind_addr = "[::1]:0"

[[simulated_sps.gimlet.components]]
id = "sp3-host-cpu"
device = "sp3-host-cpu"
Expand Down
14 changes: 12 additions & 2 deletions nexus/reconfigurator/planning/src/blueprint_builder/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,13 +925,23 @@ impl<'a> BlueprintBuilder<'a> {
match zone.disposition {
BlueprintZoneDisposition::Expunged => (),
BlueprintZoneDisposition::InService
| BlueprintZoneDisposition::Quiesced => todo!("fixme-1"),
| BlueprintZoneDisposition::Quiesced => {
return Err(Error::Planner(anyhow!(
"expunged all disks but a zone \
is still in service: {zone:?}"
)));
}
}
}
for dataset in editor.datasets(BlueprintDatasetFilter::All) {
match dataset.disposition {
BlueprintDatasetDisposition::Expunged => (),
BlueprintDatasetDisposition::InService => todo!("fixme-2"),
BlueprintDatasetDisposition::InService => {
return Err(Error::Planner(anyhow!(
"expunged all disks but a dataset \
is still in service: {dataset:?}"
)));
}
}
}

Expand Down
29 changes: 23 additions & 6 deletions smf/sp-sim/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,31 @@
#

[[simulated_sps.sidecar]]
multicast_addr = "ff15:0:1de::0"
bind_addrs = ["[::]:33300", "[::]:33301"]
serial_number = "SimSidecar0"
manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de"
device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000000"

[[simulated_sps.sidecar.network_config]]
[simulated_sps.sidecar.network_config.simulated]
bind_addr = "[::1]:33300"

[[simulated_sps.sidecar.network_config]]
[simulated_sps.sidecar.network_config.simulated]
bind_addr = "[::1]:33301"

[[simulated_sps.gimlet]]
multicast_addr = "ff15:0:1de::1"
bind_addrs = ["[::]:33310", "[::]:33311"]
serial_number = "SimGimlet0"
manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de"
device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000001"

[[simulated_sps.gimlet.network_config]]
[simulated_sps.gimlet.network_config.simulated]
bind_addr = "[::1]:33310"

[[simulated_sps.gimlet.network_config]]
[simulated_sps.gimlet.network_config.simulated]
bind_addr = "[::1]:33311"

[[simulated_sps.gimlet.components]]
id = "sp3-host-cpu"
device = "sp3-host-cpu"
Expand All @@ -26,12 +37,18 @@ presence = "Present"
serial_console = "[::1]:33312"

[[simulated_sps.gimlet]]
multicast_addr = "ff15:0:1de::2"
bind_addrs = ["[::]:33320", "[::]:33321"]
serial_number = "SimGimlet1"
manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de"
device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000002"

[[simulated_sps.gimlet.network_config]]
[simulated_sps.gimlet.network_config.simulated]
bind_addr = "[::1]:33320"

[[simulated_sps.gimlet.network_config]]
[simulated_sps.gimlet.network_config.simulated]
bind_addr = "[::1]:33321"

[[simulated_sps.gimlet.components]]
id = "sp3-host-cpu"
device = "sp3-host-cpu"
Expand Down
Loading

0 comments on commit 931801d

Please sign in to comment.