Skip to content
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

Pare down nexus-client dependencies #4503

Merged
merged 1 commit into from
Nov 16, 2023
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: 0 additions & 2 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions clients/nexus-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ futures.workspace = true
ipnetwork.workspace = true
omicron-common.workspace = true
omicron-passwords.workspace = true
sled-hardware.workspace = true
sled-storage.workspace = true
progenitor.workspace = true
regress.workspace = true
reqwest = { workspace = true, features = ["rustls-tls", "stream"] }
Expand Down
33 changes: 0 additions & 33 deletions clients/nexus-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,36 +388,3 @@ impl From<omicron_common::api::internal::shared::ExternalPortDiscovery>
}
}
}

impl From<sled_hardware::DiskVariant> for types::PhysicalDiskKind {
fn from(value: sled_hardware::DiskVariant) -> Self {
match value {
sled_hardware::DiskVariant::U2 => types::PhysicalDiskKind::U2,
sled_hardware::DiskVariant::M2 => types::PhysicalDiskKind::M2,
}
}
}

impl From<sled_hardware::Baseboard> for types::Baseboard {
fn from(b: sled_hardware::Baseboard) -> types::Baseboard {
types::Baseboard {
serial_number: b.identifier().to_string(),
part_number: b.model().to_string(),
revision: b.revision(),
}
}
}

impl From<sled_storage::dataset::DatasetKind> for types::DatasetKind {
fn from(k: sled_storage::dataset::DatasetKind) -> Self {
use sled_storage::dataset::DatasetKind::*;
match k {
CockroachDb => Self::Cockroach,
Crucible => Self::Crucible,
Clickhouse => Self::Clickhouse,
ClickhouseKeeper => Self::ClickhouseKeeper,
ExternalDns => Self::ExternalDns,
InternalDns => Self::InternalDns,
}
}
}
48 changes: 48 additions & 0 deletions sled-agent/src/nexus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,51 @@ fn d2n_record(
}
}
}

// Although it is a bit awkward to define these conversions here, it frees us
// from depending on sled_storage/sled_hardware in the nexus_client crate.

pub(crate) trait ConvertInto<T>: Sized {
fn convert(self) -> T;
}

impl ConvertInto<nexus_client::types::PhysicalDiskKind>
for sled_hardware::DiskVariant
{
fn convert(self) -> nexus_client::types::PhysicalDiskKind {
use nexus_client::types::PhysicalDiskKind;

match self {
sled_hardware::DiskVariant::U2 => PhysicalDiskKind::U2,
sled_hardware::DiskVariant::M2 => PhysicalDiskKind::M2,
}
}
}

impl ConvertInto<nexus_client::types::Baseboard> for sled_hardware::Baseboard {
fn convert(self) -> nexus_client::types::Baseboard {
nexus_client::types::Baseboard {
serial_number: self.identifier().to_string(),
part_number: self.model().to_string(),
revision: self.revision(),
}
}
}

impl ConvertInto<nexus_client::types::DatasetKind>
for sled_storage::dataset::DatasetKind
{
fn convert(self) -> nexus_client::types::DatasetKind {
use nexus_client::types::DatasetKind;
use sled_storage::dataset::DatasetKind::*;

match self {
CockroachDb => DatasetKind::Cockroach,
Crucible => DatasetKind::Crucible,
Clickhouse => DatasetKind::Clickhouse,
ClickhouseKeeper => DatasetKind::ClickhouseKeeper,
ExternalDns => DatasetKind::ExternalDns,
InternalDns => DatasetKind::InternalDns,
}
}
}
4 changes: 2 additions & 2 deletions sled-agent/src/rack_setup/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ use crate::bootstrap::early_networking::{
use crate::bootstrap::params::BootstrapAddressDiscovery;
use crate::bootstrap::params::StartSledAgentRequest;
use crate::bootstrap::rss_handle::BootstrapAgentHandle;
use crate::nexus::d2n_params;
use crate::nexus::{d2n_params, ConvertInto};
use crate::params::{
AutonomousServiceOnlyError, ServiceType, ServiceZoneRequest,
ServiceZoneService, TimeSync, ZoneType,
Expand Down Expand Up @@ -564,7 +564,7 @@ impl ServiceInner {
dataset_id: dataset.id,
request: NexusTypes::DatasetPutRequest {
address: dataset.service_address.to_string(),
kind: dataset.name.dataset().clone().into(),
kind: dataset.name.dataset().clone().convert(),
},
})
}
Expand Down
6 changes: 2 additions & 4 deletions sled-agent/src/sled_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::config::Config;
use crate::instance_manager::{InstanceManager, ReservoirMode};
use crate::long_running_tasks::LongRunningTaskHandles;
use crate::metrics::MetricsManager;
use crate::nexus::{NexusClientWithResolver, NexusRequestQueue};
use crate::nexus::{ConvertInto, NexusClientWithResolver, NexusRequestQueue};
use crate::params::{
DiskStateRequested, InstanceHardware, InstanceMigrationSourceParams,
InstancePutStateResponse, InstanceStateRequested,
Expand Down Expand Up @@ -607,9 +607,7 @@ impl SledAgent {
let nexus_client = self.inner.nexus_client.clone();
let sled_address = self.inner.sled_address();
let is_scrimlet = self.inner.hardware.is_scrimlet();
let baseboard = nexus_client::types::Baseboard::from(
self.inner.hardware.baseboard(),
);
let baseboard = self.inner.hardware.baseboard().convert();
let usable_hardware_threads =
self.inner.hardware.online_processor_count();
let usable_physical_ram =
Expand Down
6 changes: 3 additions & 3 deletions sled-agent/src/storage_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! code.

use crate::dump_setup::DumpSetup;
use crate::nexus::NexusClientWithResolver;
use crate::nexus::{ConvertInto, NexusClientWithResolver};
use derive_more::From;
use futures::stream::FuturesOrdered;
use futures::FutureExt;
Expand Down Expand Up @@ -338,7 +338,7 @@ fn compute_resource_diffs(
model: disk_id.model.clone(),
serial: disk_id.serial.clone(),
vendor: disk_id.vendor.clone(),
variant: updated_disk.variant().into(),
variant: updated_disk.variant().convert(),
});
}
if pool != updated_pool {
Expand All @@ -363,7 +363,7 @@ fn compute_resource_diffs(
model: disk_id.model.clone(),
serial: disk_id.serial.clone(),
vendor: disk_id.vendor.clone(),
variant: updated_disk.variant().into(),
variant: updated_disk.variant().convert(),
});
put_pool(disk_id, updated_pool);
}
Expand Down
Loading