Skip to content

Commit abd7542

Browse files
committed
[sled-agent] Integrate config-reconciler
1 parent 69b74a3 commit abd7542

40 files changed

+962
-3652
lines changed

Cargo.lock

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/sled-agent-client/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ progenitor::generate_api!(
6666
OmicronPhysicalDiskConfig = omicron_common::disk::OmicronPhysicalDiskConfig,
6767
OmicronPhysicalDisksConfig = omicron_common::disk::OmicronPhysicalDisksConfig,
6868
OmicronSledConfig = nexus_sled_agent_shared::inventory::OmicronSledConfig,
69-
OmicronSledConfigResult = nexus_sled_agent_shared::inventory::OmicronSledConfigResult,
7069
OmicronZoneConfig = nexus_sled_agent_shared::inventory::OmicronZoneConfig,
7170
OmicronZoneDataset = nexus_sled_agent_shared::inventory::OmicronZoneDataset,
7271
OmicronZoneImageSource = nexus_sled_agent_shared::inventory::OmicronZoneImageSource,

common/src/disk.rs

+8
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ pub struct OmicronPhysicalDiskConfig {
4343
pub pool_id: ZpoolUuid,
4444
}
4545

46+
impl IdMappable for OmicronPhysicalDiskConfig {
47+
type Id = PhysicalDiskUuid;
48+
49+
fn id(&self) -> Self::Id {
50+
self.id
51+
}
52+
}
53+
4654
#[derive(
4755
Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq, Eq, Hash,
4856
)]

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

-52
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@ enum SledAgentCommands {
3434
#[clap(subcommand)]
3535
Zones(ZoneCommands),
3636

37-
/// print information about zpools
38-
#[clap(subcommand)]
39-
Zpools(ZpoolCommands),
40-
41-
/// print information about datasets
42-
#[clap(subcommand)]
43-
Datasets(DatasetCommands),
44-
4537
/// print information about the local bootstore node
4638
#[clap(subcommand)]
4739
Bootstore(BootstoreCommands),
@@ -97,12 +89,6 @@ impl SledAgentArgs {
9789
SledAgentCommands::Zones(ZoneCommands::List) => {
9890
cmd_zones_list(&client).await
9991
}
100-
SledAgentCommands::Zpools(ZpoolCommands::List) => {
101-
cmd_zpools_list(&client).await
102-
}
103-
SledAgentCommands::Datasets(DatasetCommands::List) => {
104-
cmd_datasets_list(&client).await
105-
}
10692
SledAgentCommands::Bootstore(BootstoreCommands::Status) => {
10793
cmd_bootstore_status(&client).await
10894
}
@@ -129,44 +115,6 @@ async fn cmd_zones_list(
129115
Ok(())
130116
}
131117

132-
/// Runs `omdb sled-agent zpools list`
133-
async fn cmd_zpools_list(
134-
client: &sled_agent_client::Client,
135-
) -> Result<(), anyhow::Error> {
136-
let response = client.zpools_get().await.context("listing zpools")?;
137-
let zpools = response.into_inner();
138-
139-
println!("zpools:");
140-
if zpools.is_empty() {
141-
println!(" <none>");
142-
}
143-
for zpool in &zpools {
144-
println!(" {:?}", zpool);
145-
}
146-
147-
Ok(())
148-
}
149-
150-
/// Runs `omdb sled-agent datasets list`
151-
async fn cmd_datasets_list(
152-
client: &sled_agent_client::Client,
153-
) -> Result<(), anyhow::Error> {
154-
let response = client.datasets_get().await.context("listing datasets")?;
155-
let response = response.into_inner();
156-
157-
println!("dataset configuration @ generation {}:", response.generation);
158-
let datasets = response.datasets;
159-
160-
if datasets.is_empty() {
161-
println!(" <none>");
162-
}
163-
for dataset in &datasets {
164-
println!(" {:?}", dataset);
165-
}
166-
167-
Ok(())
168-
}
169-
170118
/// Runs `omdb sled-agent bootstore status`
171119
async fn cmd_bootstore_status(
172120
client: &sled_agent_client::Client,

nexus-sled-agent-shared/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ workspace = true
88

99
[dependencies]
1010
daft.workspace = true
11+
id-map.workspace = true
1112
illumos-utils.workspace = true
1213
omicron-common.workspace = true
1314
omicron-passwords.workspace = true

nexus-sled-agent-shared/src/inventory.rs

+15-20
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@
77
use std::net::{IpAddr, Ipv6Addr, SocketAddr, SocketAddrV6};
88

99
use daft::Diffable;
10+
use id_map::{IdMap, IdMappable};
1011
use omicron_common::{
1112
api::{
1213
external::{ByteCount, Generation},
1314
internal::shared::{NetworkInterface, SourceNatConfig},
1415
},
15-
disk::{
16-
DatasetManagementStatus, DatasetsConfig, DiskManagementStatus,
17-
DiskVariant, OmicronPhysicalDisksConfig,
18-
},
16+
disk::{DatasetConfig, DiskVariant, OmicronPhysicalDiskConfig},
1917
zpool_name::ZpoolName,
2018
};
2119
use omicron_uuid_kinds::{DatasetUuid, OmicronZoneUuid};
@@ -128,23 +126,12 @@ pub enum SledRole {
128126
}
129127

130128
/// Describes the set of Reconfigurator-managed configuration elements of a sled
131-
// TODO this struct should have a generation number; at the moment, each of
132-
// the fields has a separete one internally.
133-
#[derive(
134-
Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq, Eq, Hash,
135-
)]
129+
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq, Eq)]
136130
pub struct OmicronSledConfig {
137-
pub disks_config: OmicronPhysicalDisksConfig,
138-
pub datasets_config: DatasetsConfig,
139-
pub zones_config: OmicronZonesConfig,
140-
}
141-
142-
/// Result of the currently-synchronous `omicron_config_put` endpoint.
143-
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
144-
#[must_use = "this `DatasetManagementResult` may contain errors, which should be handled"]
145-
pub struct OmicronSledConfigResult {
146-
pub disks: Vec<DiskManagementStatus>,
147-
pub datasets: Vec<DatasetManagementStatus>,
131+
pub generation: Generation,
132+
pub disks: IdMap<OmicronPhysicalDiskConfig>,
133+
pub datasets: IdMap<DatasetConfig>,
134+
pub zones: IdMap<OmicronZoneConfig>,
148135
}
149136

150137
/// Describes the set of Omicron-managed zones running on a sled
@@ -190,6 +177,14 @@ pub struct OmicronZoneConfig {
190177
pub image_source: OmicronZoneImageSource,
191178
}
192179

180+
impl IdMappable for OmicronZoneConfig {
181+
type Id = OmicronZoneUuid;
182+
183+
fn id(&self) -> Self::Id {
184+
self.id
185+
}
186+
}
187+
193188
impl OmicronZoneConfig {
194189
/// Returns the underlay IP address associated with this zone.
195190
///

nexus/inventory/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ clickhouse-admin-types.workspace = true
1717
futures.workspace = true
1818
gateway-client.workspace = true
1919
gateway-messages.workspace = true
20+
id-map.workspace = true
2021
nexus-sled-agent-shared.workspace = true
2122
nexus-types.workspace = true
2223
omicron-common.workspace = true

nexus/inventory/src/collector.rs

+14-16
Original file line numberDiff line numberDiff line change
@@ -408,15 +408,13 @@ mod test {
408408
use super::Collector;
409409
use crate::StaticSledAgentEnumerator;
410410
use gateway_messages::SpPort;
411+
use id_map::IdMap;
411412
use nexus_sled_agent_shared::inventory::OmicronSledConfig;
412413
use nexus_sled_agent_shared::inventory::OmicronZoneConfig;
413414
use nexus_sled_agent_shared::inventory::OmicronZoneImageSource;
414415
use nexus_sled_agent_shared::inventory::OmicronZoneType;
415-
use nexus_sled_agent_shared::inventory::OmicronZonesConfig;
416416
use nexus_types::inventory::Collection;
417417
use omicron_common::api::external::Generation;
418-
use omicron_common::disk::DatasetsConfig;
419-
use omicron_common::disk::OmicronPhysicalDisksConfig;
420418
use omicron_common::zpool_name::ZpoolName;
421419
use omicron_sled_agent::sim;
422420
use omicron_uuid_kinds::OmicronZoneUuid;
@@ -595,19 +593,19 @@ mod test {
595593
let zone_address = SocketAddrV6::new(Ipv6Addr::LOCALHOST, 123, 0, 0);
596594
client
597595
.omicron_config_put(&OmicronSledConfig {
598-
disks_config: OmicronPhysicalDisksConfig::default(),
599-
datasets_config: DatasetsConfig::default(),
600-
zones_config: OmicronZonesConfig {
601-
generation: Generation::from(3),
602-
zones: vec![OmicronZoneConfig {
603-
id: zone_id,
604-
zone_type: OmicronZoneType::Oximeter {
605-
address: zone_address,
606-
},
607-
filesystem_pool: Some(filesystem_pool),
608-
image_source: OmicronZoneImageSource::InstallDataset,
609-
}],
610-
},
596+
generation: Generation::from(3),
597+
disks: IdMap::default(),
598+
datasets: IdMap::default(),
599+
zones: [OmicronZoneConfig {
600+
id: zone_id,
601+
zone_type: OmicronZoneType::Oximeter {
602+
address: zone_address,
603+
},
604+
filesystem_pool: Some(filesystem_pool),
605+
image_source: OmicronZoneImageSource::InstallDataset,
606+
}]
607+
.into_iter()
608+
.collect(),
611609
})
612610
.await
613611
.expect("failed to write initial zone version to fake sled agent");

0 commit comments

Comments
 (0)