Skip to content

Commit ee657cc

Browse files
committed
Merge branch 'affinity-db-model' into affinity-db-crud
2 parents eee1d6f + 7a99a96 commit ee657cc

File tree

15 files changed

+324
-100
lines changed

15 files changed

+324
-100
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ nexus-test-interface = { path = "nexus/test-interface" }
494494
nexus-test-utils-macros = { path = "nexus/test-utils-macros" }
495495
nexus-test-utils = { path = "nexus/test-utils" }
496496
nexus-types = { path = "nexus/types" }
497+
nix = { version = "0.29", features = ["net"] }
497498
nom = "7.1.3"
498499
num-integer = "0.1.46"
499500
num = { version = "0.4.3", default-features = false, features = [ "libm" ] }

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

Lines changed: 111 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,7 @@ async fn cmd_db_disk_info(
15631563
struct DownstairsRow {
15641564
host_serial: String,
15651565
region: String,
1566-
zone: String,
1566+
dataset: String,
15671567
physical_disk: String,
15681568
}
15691569

@@ -1688,7 +1688,7 @@ async fn cmd_db_disk_info(
16881688
rows.push(DownstairsRow {
16891689
host_serial: my_sled.serial_number().to_string(),
16901690
region: region.id().to_string(),
1691-
zone: format!("oxz_crucible_{}", dataset.id()),
1691+
dataset: dataset.id().to_string(),
16921692
physical_disk: my_zpool.physical_disk_id.to_string(),
16931693
});
16941694
}
@@ -1724,7 +1724,7 @@ async fn get_and_display_vcr(
17241724
for v in volumes {
17251725
match serde_json::from_str(&v.data()) {
17261726
Ok(vcr) => {
1727-
println!("\nVCR from volume ID {volume_id}");
1727+
println!("VCR from volume ID {volume_id}");
17281728
print_vcr(vcr, 0);
17291729
}
17301730
Err(e) => {
@@ -2125,45 +2125,88 @@ async fn cmd_db_snapshot_info(
21252125
struct DownstairsRow {
21262126
host_serial: String,
21272127
region: String,
2128-
zone: String,
2128+
dataset: String,
21292129
physical_disk: String,
21302130
}
21312131

21322132
use db::schema::snapshot::dsl as snapshot_dsl;
2133-
let snapshots = snapshot_dsl::snapshot
2133+
let mut snapshots = snapshot_dsl::snapshot
21342134
.filter(snapshot_dsl::id.eq(args.uuid))
21352135
.limit(1)
21362136
.select(Snapshot::as_select())
21372137
.load_async(&*datastore.pool_connection_for_tests().await?)
21382138
.await
21392139
.context("loading requested snapshot")?;
21402140

2141-
let mut dest_volume_ids = Vec::new();
2142-
let mut source_volume_ids = Vec::new();
2143-
let rows = snapshots.into_iter().map(|snapshot| {
2144-
dest_volume_ids.push(snapshot.destination_volume_id());
2145-
source_volume_ids.push(snapshot.volume_id());
2146-
SnapshotRow::from(snapshot)
2147-
});
2148-
if rows.len() == 0 {
2149-
bail!("No snapshout with UUID: {} found", args.uuid);
2141+
if snapshots.is_empty() {
2142+
bail!("No snapshot with UUID: {} found", args.uuid);
21502143
}
2144+
let snap = snapshots.pop().expect("Found more that one snapshot");
21512145

2152-
let table = tabled::Table::new(rows)
2153-
.with(tabled::settings::Style::empty())
2154-
.with(tabled::settings::Padding::new(0, 1, 0, 0))
2155-
.to_string();
2146+
let dest_vol_id = snap.destination_volume_id;
2147+
let source_vol_id = snap.volume_id;
2148+
let snap = SnapshotRow::from(snap);
21562149

2157-
println!("{}", table);
2150+
println!(" Name: {}", snap.snap_name);
2151+
println!(" id: {}", snap.id);
2152+
println!(" state: {}", snap.state);
2153+
println!(" size: {}", snap.size);
2154+
println!(" source_disk_id: {}", snap.source_disk_id);
2155+
println!(" source_volume_id: {}", snap.source_volume_id);
2156+
println!("destination_volume_id: {}", snap.destination_volume_id);
21582157

2159-
println!("SOURCE VOLUME VCR:");
2160-
for vol in source_volume_ids {
2161-
get_and_display_vcr(vol, datastore).await?;
2158+
use db::schema::region_snapshot::dsl as region_snapshot_dsl;
2159+
let region_snapshots = region_snapshot_dsl::region_snapshot
2160+
.filter(region_snapshot_dsl::snapshot_id.eq(args.uuid))
2161+
.select(RegionSnapshot::as_select())
2162+
.load_async(&*datastore.pool_connection_for_tests().await?)
2163+
.await
2164+
.context("loading region snapshots")?;
2165+
2166+
println!();
2167+
if region_snapshots.is_empty() {
2168+
println!("No region snapshot info found");
2169+
} else {
2170+
// The row describing the region_snapshot.
2171+
#[derive(Tabled)]
2172+
#[tabled(rename_all = "SCREAMING_SNAKE_CASE")]
2173+
struct RegionSnapshotRow {
2174+
dataset_id: String,
2175+
region_id: String,
2176+
snapshot_id: String,
2177+
snapshot_addr: String,
2178+
volume_references: String,
2179+
}
2180+
let mut rsnap = Vec::new();
2181+
2182+
// From each region snapshot:
2183+
// Collect the snapshot IDs for later use.
2184+
// Display the region snapshot rows.
2185+
let mut snapshot_ids = HashSet::new();
2186+
for rs in region_snapshots {
2187+
snapshot_ids.insert(rs.snapshot_id);
2188+
let rs = RegionSnapshotRow {
2189+
dataset_id: rs.dataset_id.to_string(),
2190+
region_id: rs.region_id.to_string(),
2191+
snapshot_id: rs.snapshot_id.to_string(),
2192+
snapshot_addr: rs.snapshot_addr.to_string(),
2193+
volume_references: rs.volume_references.to_string(),
2194+
};
2195+
rsnap.push(rs);
2196+
}
2197+
let table = tabled::Table::new(rsnap)
2198+
.with(tabled::settings::Style::empty())
2199+
.with(tabled::settings::Padding::new(0, 1, 0, 0))
2200+
.to_string();
2201+
2202+
println!("REGION SNAPSHOT INFO:");
2203+
println!("{}", table);
21622204
}
2163-
for vol_id in dest_volume_ids {
2164-
// Get the dataset backing this volume.
2165-
let regions = datastore.get_allocated_regions(vol_id).await?;
21662205

2206+
let regions = datastore.get_allocated_regions(source_vol_id.into()).await?;
2207+
if regions.is_empty() {
2208+
println!("\nNo source region info found");
2209+
} else {
21672210
let mut rows = Vec::with_capacity(3);
21682211
for (dataset, region) in regions {
21692212
let my_pool_id = dataset.pool_id;
@@ -2184,7 +2227,7 @@ async fn cmd_db_snapshot_info(
21842227
rows.push(DownstairsRow {
21852228
host_serial: my_sled.serial_number().to_string(),
21862229
region: region.id().to_string(),
2187-
zone: format!("oxz_crucible_{}", dataset.id()),
2230+
dataset: dataset.id().to_string(),
21882231
physical_disk: my_zpool.physical_disk_id.to_string(),
21892232
});
21902233
}
@@ -2194,12 +2237,51 @@ async fn cmd_db_snapshot_info(
21942237
.with(tabled::settings::Padding::new(0, 1, 0, 0))
21952238
.to_string();
21962239

2197-
println!("DESTINATION REGION INFO:");
2240+
println!("\nSOURCE REGION INFO:");
21982241
println!("{}", table);
2199-
println!("DESTINATION VOLUME VCR:");
2200-
get_and_display_vcr(vol_id, datastore).await?;
22012242
}
22022243

2244+
println!("SOURCE VOLUME VCR:");
2245+
get_and_display_vcr(source_vol_id.into(), datastore).await?;
2246+
2247+
// Get the dataset backing this volume.
2248+
let regions = datastore.get_allocated_regions(dest_vol_id.into()).await?;
2249+
2250+
let mut rows = Vec::with_capacity(3);
2251+
for (dataset, region) in regions {
2252+
let my_pool_id = dataset.pool_id;
2253+
let (_, my_zpool) = LookupPath::new(opctx, datastore)
2254+
.zpool_id(my_pool_id)
2255+
.fetch()
2256+
.await
2257+
.context("failed to look up zpool")?;
2258+
2259+
let my_sled_id = my_zpool.sled_id;
2260+
2261+
let (_, my_sled) = LookupPath::new(opctx, datastore)
2262+
.sled_id(my_sled_id)
2263+
.fetch()
2264+
.await
2265+
.context("failed to look up sled")?;
2266+
2267+
rows.push(DownstairsRow {
2268+
host_serial: my_sled.serial_number().to_string(),
2269+
region: region.id().to_string(),
2270+
dataset: dataset.id().to_string(),
2271+
physical_disk: my_zpool.physical_disk_id.to_string(),
2272+
});
2273+
}
2274+
2275+
let table = tabled::Table::new(rows)
2276+
.with(tabled::settings::Style::empty())
2277+
.with(tabled::settings::Padding::new(0, 1, 0, 0))
2278+
.to_string();
2279+
2280+
println!("DESTINATION REGION INFO:");
2281+
println!("{}", table);
2282+
println!("DESTINATION VOLUME VCR:");
2283+
get_and_display_vcr(dest_vol_id.into(), datastore).await?;
2284+
22032285
Ok(())
22042286
}
22052287

gateway-test-utils/configs/sp_sim_config.test.toml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@
88
# concurrently.
99
#
1010
[[simulated_sps.sidecar]]
11-
multicast_addr = "::1"
12-
bind_addrs = ["[::1]:0", "[::1]:0"]
1311
serial_number = "SimSidecar0"
1412
manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de"
1513
device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000000"
1614

15+
[[simulated_sps.sidecar.network_config]]
16+
[simulated_sps.sidecar.network_config.simulated]
17+
bind_addr = "[::1]:0"
18+
19+
[[simulated_sps.sidecar.network_config]]
20+
[simulated_sps.sidecar.network_config.simulated]
21+
bind_addr = "[::1]:0"
22+
1723
[[simulated_sps.sidecar.components]]
1824
id = "dev-0"
1925
device = "fake-tmp-sensor"
@@ -35,19 +41,31 @@ sensors = [
3541
]
3642

3743
[[simulated_sps.sidecar]]
38-
multicast_addr = "::1"
39-
bind_addrs = ["[::1]:0", "[::1]:0"]
4044
serial_number = "SimSidecar1"
4145
manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de"
4246
device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000001"
4347

48+
[[simulated_sps.sidecar.network_config]]
49+
[simulated_sps.sidecar.network_config.simulated]
50+
bind_addr = "[::1]:0"
51+
52+
[[simulated_sps.sidecar.network_config]]
53+
[simulated_sps.sidecar.network_config.simulated]
54+
bind_addr = "[::1]:0"
55+
4456
[[simulated_sps.gimlet]]
45-
multicast_addr = "::1"
46-
bind_addrs = ["[::1]:0", "[::1]:0"]
4757
serial_number = "SimGimlet00"
4858
manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de"
4959
device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000002"
5060

61+
[[simulated_sps.gimlet.network_config]]
62+
[simulated_sps.gimlet.network_config.simulated]
63+
bind_addr = "[::1]:0"
64+
65+
[[simulated_sps.gimlet.network_config]]
66+
[simulated_sps.gimlet.network_config.simulated]
67+
bind_addr = "[::1]:0"
68+
5169
[[simulated_sps.gimlet.components]]
5270
id = "sp3-host-cpu"
5371
device = "sp3-host-cpu"
@@ -151,12 +169,18 @@ sensors = [
151169

152170

153171
[[simulated_sps.gimlet]]
154-
multicast_addr = "::1"
155-
bind_addrs = ["[::1]:0", "[::1]:0"]
156172
serial_number = "SimGimlet01"
157173
manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de"
158174
device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000003"
159175

176+
[[simulated_sps.gimlet.network_config]]
177+
[simulated_sps.gimlet.network_config.simulated]
178+
bind_addr = "[::1]:0"
179+
180+
[[simulated_sps.gimlet.network_config]]
181+
[simulated_sps.gimlet.network_config.simulated]
182+
bind_addr = "[::1]:0"
183+
160184
[[simulated_sps.gimlet.components]]
161185
id = "sp3-host-cpu"
162186
device = "sp3-host-cpu"

nexus/reconfigurator/planning/src/blueprint_builder/builder.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,13 +925,23 @@ impl<'a> BlueprintBuilder<'a> {
925925
match zone.disposition {
926926
BlueprintZoneDisposition::Expunged => (),
927927
BlueprintZoneDisposition::InService
928-
| BlueprintZoneDisposition::Quiesced => todo!("fixme-1"),
928+
| BlueprintZoneDisposition::Quiesced => {
929+
return Err(Error::Planner(anyhow!(
930+
"expunged all disks but a zone \
931+
is still in service: {zone:?}"
932+
)));
933+
}
929934
}
930935
}
931936
for dataset in editor.datasets(BlueprintDatasetFilter::All) {
932937
match dataset.disposition {
933938
BlueprintDatasetDisposition::Expunged => (),
934-
BlueprintDatasetDisposition::InService => todo!("fixme-2"),
939+
BlueprintDatasetDisposition::InService => {
940+
return Err(Error::Planner(anyhow!(
941+
"expunged all disks but a dataset \
942+
is still in service: {dataset:?}"
943+
)));
944+
}
935945
}
936946
}
937947

smf/sp-sim/config.toml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,31 @@
33
#
44

55
[[simulated_sps.sidecar]]
6-
multicast_addr = "ff15:0:1de::0"
7-
bind_addrs = ["[::]:33300", "[::]:33301"]
86
serial_number = "SimSidecar0"
97
manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de"
108
device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000000"
119

10+
[[simulated_sps.sidecar.network_config]]
11+
[simulated_sps.sidecar.network_config.simulated]
12+
bind_addr = "[::1]:33300"
13+
14+
[[simulated_sps.sidecar.network_config]]
15+
[simulated_sps.sidecar.network_config.simulated]
16+
bind_addr = "[::1]:33301"
1217

1318
[[simulated_sps.gimlet]]
14-
multicast_addr = "ff15:0:1de::1"
15-
bind_addrs = ["[::]:33310", "[::]:33311"]
1619
serial_number = "SimGimlet0"
1720
manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de"
1821
device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000001"
1922

23+
[[simulated_sps.gimlet.network_config]]
24+
[simulated_sps.gimlet.network_config.simulated]
25+
bind_addr = "[::1]:33310"
26+
27+
[[simulated_sps.gimlet.network_config]]
28+
[simulated_sps.gimlet.network_config.simulated]
29+
bind_addr = "[::1]:33311"
30+
2031
[[simulated_sps.gimlet.components]]
2132
id = "sp3-host-cpu"
2233
device = "sp3-host-cpu"
@@ -26,12 +37,18 @@ presence = "Present"
2637
serial_console = "[::1]:33312"
2738

2839
[[simulated_sps.gimlet]]
29-
multicast_addr = "ff15:0:1de::2"
30-
bind_addrs = ["[::]:33320", "[::]:33321"]
3140
serial_number = "SimGimlet1"
3241
manufacturing_root_cert_seed = "01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de01de"
3342
device_id_cert_seed = "01de000000000000000000000000000000000000000000000000000000000002"
3443

44+
[[simulated_sps.gimlet.network_config]]
45+
[simulated_sps.gimlet.network_config.simulated]
46+
bind_addr = "[::1]:33320"
47+
48+
[[simulated_sps.gimlet.network_config]]
49+
[simulated_sps.gimlet.network_config.simulated]
50+
bind_addr = "[::1]:33321"
51+
3552
[[simulated_sps.gimlet.components]]
3653
id = "sp3-host-cpu"
3754
device = "sp3-host-cpu"

0 commit comments

Comments
 (0)