Skip to content

Commit 5ec45d3

Browse files
committed
sled-agent needs to expose cpu_family for inventory collections too
the existing plumbing was sufficient for sled-agent to report the CPU family at startup, but did not provide the CPU family when Nexus calls later for inventory collections. when you've upgraded to this version, the database migration sets the sled CPU family to `unknown` expecting that the next inventory collection will figure things out. this doesn't happen, and the initial check-in doesn't update the CPU type either (presumably because the sled is already known and initialized from the control plane's perspective?) this does... most of the plumbing to report a sled's CPU family for inventory collection, but it doesn't actually work. `SledCpuFamily` being both in `omicron-common` and `nexus-client` is kind of unworkable. probably need a `ConvertInto` or something to transform the shared into the `nexus-client` when needed..? i've been trying to figure out what exactly is necessary and what is just building a mess for myself for two hours and this feels like it's going nowhere.
1 parent 4c40d47 commit 5ec45d3

File tree

15 files changed

+64
-28
lines changed

15 files changed

+64
-28
lines changed

common/src/api/internal/shared.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,39 @@ pub struct SledIdentifiers {
11011101
pub serial: String,
11021102
}
11031103

1104+
/// Identifies the kind of CPU present on a sled, determined by reading CPUID.
1105+
#[derive(Serialize, Deserialize, Copy, Clone, Debug, PartialEq, Eq, JsonSchema)]
1106+
#[serde(rename_all = "snake_case")]
1107+
pub enum SledCpuFamily {
1108+
/// The CPU vendor or its family number don't correspond to any of the
1109+
/// known family variants.
1110+
Unknown,
1111+
1112+
/// AMD Milan processors (or very close). Could be an actual Milan in a
1113+
/// Gimlet, a close-to-Milan client Zen 3 part, or Zen 4 (for which Milan is
1114+
/// the greatest common denominator).
1115+
AmdMilan,
1116+
1117+
/// AMD Turin processors (or very close). Could be an actual Turin in a
1118+
/// Cosmo, or a close-to-Turin client Zen 5 part.
1119+
AmdTurin,
1120+
1121+
/// AMD Turin Dense processors. There are no "Turin Dense-like" CPUs unlike
1122+
/// other cases, so this means a bona fide Zen 5c Turin Dense part.
1123+
AmdTurinDense,
1124+
}
1125+
1126+
impl fmt::Display for SledCpuFamily {
1127+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1128+
match self {
1129+
SledCpuFamily::Unknown => write!(f, "unknown"),
1130+
SledCpuFamily::AmdMilan => write!(f, "milan"),
1131+
SledCpuFamily::AmdTurin => write!(f, "turin"),
1132+
SledCpuFamily::AmdTurinDense => write!(f, "turin_dense"),
1133+
}
1134+
}
1135+
}
1136+
11041137
#[cfg(test)]
11051138
mod tests {
11061139
use super::*;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use omicron_common::update::OmicronZoneManifestSource;
2626
use omicron_common::{
2727
api::{
2828
external::{ByteCount, Generation},
29-
internal::shared::{NetworkInterface, SourceNatConfig},
29+
internal::shared::{NetworkInterface, SourceNatConfig, SledCpuFamily},
3030
},
3131
disk::{DatasetConfig, DiskVariant, OmicronPhysicalDiskConfig},
3232
update::ArtifactId,
@@ -121,6 +121,7 @@ pub struct Inventory {
121121
pub baseboard: Baseboard,
122122
pub usable_hardware_threads: u32,
123123
pub usable_physical_ram: ByteCount,
124+
pub cpu_family: SledCpuFamily,
124125
pub reservoir_size: ByteCount,
125126
pub disks: Vec<InventoryDisk>,
126127
pub zpools: Vec<InventoryZpool>,

nexus/db-model/src/inventory.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::ArtifactHash;
88
use crate::Generation;
99
use crate::PhysicalDiskKind;
1010
use crate::omicron_zone_config::{self, OmicronZoneNic};
11+
use crate::sled_cpu_family::SledCpuFamily;
1112
use crate::typed_uuid::DbTypedUuid;
1213
use crate::{
1314
ByteCount, MacAddr, Name, ServiceKind, SqlU8, SqlU16, SqlU32,
@@ -887,6 +888,7 @@ pub struct InvSledAgent {
887888
pub sled_role: SledRole,
888889
pub usable_hardware_threads: SqlU32,
889890
pub usable_physical_ram: ByteCount,
891+
pub cpu_family: SledCpuFamily,
890892
pub reservoir_size: ByteCount,
891893
// Soft foreign key to an `InvOmicronSledConfig`
892894
pub ledgered_sled_config: Option<DbTypedUuid<OmicronSledConfigKind>>,
@@ -1300,6 +1302,7 @@ impl InvSledAgent {
13001302
usable_physical_ram: ByteCount::from(
13011303
sled_agent.usable_physical_ram,
13021304
),
1305+
cpu_family: sled_agent.cpu_family.into(),
13031306
reservoir_size: ByteCount::from(sled_agent.reservoir_size),
13041307
ledgered_sled_config: ledgered_sled_config.map(From::from),
13051308
reconciler_status,

nexus/db-model/src/sled_cpu_family.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ impl_enum_type!(
2626
AmdTurinDense => b"amd_turin_dense"
2727
);
2828

29-
impl From<nexus_types::internal_api::params::SledCpuFamily> for SledCpuFamily {
30-
fn from(value: nexus_types::internal_api::params::SledCpuFamily) -> Self {
31-
use nexus_types::internal_api::params::SledCpuFamily as InputFamily;
29+
impl From<omicron_common::api::internal::shared::SledCpuFamily> for SledCpuFamily {
30+
fn from(value: omicron_common::api::internal::shared::SledCpuFamily) -> Self {
31+
use omicron_common::api::internal::shared::SledCpuFamily as InputFamily;
3232
match value {
3333
InputFamily::Unknown => Self::Unknown,
3434
InputFamily::AmdMilan => Self::AmdMilan,
@@ -38,7 +38,7 @@ impl From<nexus_types::internal_api::params::SledCpuFamily> for SledCpuFamily {
3838
}
3939
}
4040

41-
impl From<SledCpuFamily> for nexus_types::internal_api::params::SledCpuFamily {
41+
impl From<SledCpuFamily> for omicron_common::api::internal::shared::SledCpuFamily {
4242
fn from(value: SledCpuFamily) -> Self {
4343
match value {
4444
SledCpuFamily::Unknown => Self::Unknown,

nexus/db-queries/src/db/datastore/inventory.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,8 @@ impl DataStore {
13851385
sled_agent.usable_physical_ram,
13861386
)
13871387
.into_sql::<diesel::sql_types::Int8>(),
1388+
nexus_db_model::SledCpuFamily::from(sled_agent.cpu_family)
1389+
.into_sql::<nexus_db_schema::enums::SledCpuFamilyEnum>(),
13881390
nexus_db_model::ByteCount::from(
13891391
sled_agent.reservoir_size,
13901392
)
@@ -1439,6 +1441,7 @@ impl DataStore {
14391441
sa_dsl::sled_role,
14401442
sa_dsl::usable_hardware_threads,
14411443
sa_dsl::usable_physical_ram,
1444+
sa_dsl::cpu_family,
14421445
sa_dsl::reservoir_size,
14431446
sa_dsl::ledgered_sled_config,
14441447
sa_dsl::reconciler_status_kind,
@@ -1470,6 +1473,7 @@ impl DataStore {
14701473
_sled_role,
14711474
_usable_hardware_threads,
14721475
_usable_physical_ram,
1476+
_cpu_family,
14731477
_reservoir_size,
14741478
_ledgered_sled_config,
14751479
_reconciler_status_kind,
@@ -3846,6 +3850,7 @@ impl DataStore {
38463850
sled_role: s.sled_role.into(),
38473851
usable_hardware_threads: u32::from(s.usable_hardware_threads),
38483852
usable_physical_ram: s.usable_physical_ram.into(),
3853+
cpu_family: s.cpu_family.into(),
38493854
reservoir_size: s.reservoir_size.into(),
38503855
// For disks, zpools, and datasets, the map for a sled ID is
38513856
// only populated if there is at least one disk/zpool/dataset

nexus/db-schema/src/schema.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,7 @@ table! {
16091609
sled_role -> crate::enums::SledRoleEnum,
16101610
usable_hardware_threads -> Int8,
16111611
usable_physical_ram -> Int8,
1612+
cpu_family -> crate::enums::SledCpuFamilyEnum,
16121613
reservoir_size -> Int8,
16131614

16141615
ledgered_sled_config -> Nullable<Uuid>,

nexus/inventory/src/builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ impl CollectionBuilder {
595595
baseboard_id,
596596
usable_hardware_threads: inventory.usable_hardware_threads,
597597
usable_physical_ram: inventory.usable_physical_ram,
598+
cpu_family: inventory.cpu_family,
598599
reservoir_size: inventory.reservoir_size,
599600
time_collected,
600601
sled_id,

nexus/inventory/src/examples.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ use nexus_types::inventory::ZpoolName;
4040
use omicron_cockroach_metrics::MetricValue;
4141
use omicron_cockroach_metrics::PrometheusMetrics;
4242
use omicron_common::api::external::ByteCount;
43+
use omicron_common::api::internal::shared::SledCpuFamily;
4344
use omicron_common::disk::DatasetConfig;
4445
use omicron_common::disk::DatasetKind;
4546
use omicron_common::disk::DatasetName;
@@ -957,6 +958,7 @@ pub fn sled_agent(
957958
sled_id,
958959
usable_hardware_threads: 10,
959960
usable_physical_ram: ByteCount::from(1024 * 1024),
961+
cpu_family: SledCpuFamily::AmdMilan,
960962
disks,
961963
zpools,
962964
datasets,

nexus/reconfigurator/planning/src/system.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ use omicron_common::address::SLED_PREFIX;
5757
use omicron_common::address::get_sled_address;
5858
use omicron_common::api::external::ByteCount;
5959
use omicron_common::api::external::Generation;
60+
use omicron_common::api::internal::shared::SledCpuFamily;
6061
use omicron_common::disk::DiskIdentity;
6162
use omicron_common::disk::DiskVariant;
6263
use omicron_common::disk::M2Slot;
@@ -1071,6 +1072,7 @@ impl Sled {
10711072
sled_id,
10721073
usable_hardware_threads: 10,
10731074
usable_physical_ram: ByteCount::from(1024 * 1024),
1075+
cpu_family: SledCpuFamily::AmdMilan,
10741076
// Populate disks, appearing like a real device.
10751077
disks: zpools
10761078
.values()
@@ -1267,6 +1269,7 @@ impl Sled {
12671269
sled_id,
12681270
usable_hardware_threads: inv_sled_agent.usable_hardware_threads,
12691271
usable_physical_ram: inv_sled_agent.usable_physical_ram,
1272+
cpu_family: inv_sled_agent.cpu_family,
12701273
disks: vec![],
12711274
zpools: vec![],
12721275
datasets: vec![],

nexus/types/src/internal_api/params.rs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use omicron_common::api::internal::nexus::Certificate;
1818
use omicron_common::api::internal::shared::AllowedSourceIps;
1919
use omicron_common::api::internal::shared::ExternalPortDiscovery;
2020
use omicron_common::api::internal::shared::RackNetworkConfig;
21+
use omicron_common::api::internal::shared::SledCpuFamily;
2122
use omicron_common::api::internal::shared::SourceNatConfig;
2223
use omicron_uuid_kinds::DatasetUuid;
2324
use omicron_uuid_kinds::PhysicalDiskUuid;
@@ -30,28 +31,6 @@ use std::net::SocketAddr;
3031
use std::net::SocketAddrV6;
3132
use uuid::Uuid;
3233

33-
/// Identifies the kind of CPU present on a sled, determined by reading CPUID.
34-
#[derive(Serialize, Deserialize, Debug, JsonSchema)]
35-
#[serde(rename_all = "snake_case")]
36-
pub enum SledCpuFamily {
37-
/// The CPU vendor or its family number don't correspond to any of the
38-
/// known family variants.
39-
Unknown,
40-
41-
/// AMD Milan processors (or very close). Could be an actual Milan in a
42-
/// Gimlet, a close-to-Milan client Zen 3 part, or Zen 4 (for which Milan is
43-
/// the greatest common denominator).
44-
AmdMilan,
45-
46-
/// AMD Turin processors (or very close). Could be an actual Turin in a
47-
/// Cosmo, or a close-to-Turin client Zen 5 part.
48-
AmdTurin,
49-
50-
/// AMD Turin Dense processors. There are no "Turin Dense-like" CPUs unlike
51-
/// other cases, so this means a bona fide Zen 5c Turin Dense part.
52-
AmdTurinDense,
53-
}
54-
5534
/// Sent by a sled agent to Nexus to inform about resources
5635
#[derive(Serialize, Deserialize, Debug, JsonSchema)]
5736
pub struct SledAgentInfo {

0 commit comments

Comments
 (0)