Skip to content

make sleds report their CPU families to Nexus #8725

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

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions dev-tools/reconfigurator-cli/tests/output/cmds-example-stdout
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,7 @@ sled 2eb69596-f081-4e2d-9425-9994926e0832 (role = Gimlet, serial serial1)
found at: <REDACTED_TIMESTAMP> from fake sled agent
address: [fd00:1122:3344:102::1]:12345
usable hw threads: 10
CPU family: amd_milan
usable memory (GiB): 0
reservoir (GiB): 0
physical disks:
Expand Down Expand Up @@ -1210,6 +1211,7 @@ sled 32d8d836-4d8a-4e54-8fa9-f31d79c42646 (role = Gimlet, serial serial2)
found at: <REDACTED_TIMESTAMP> from fake sled agent
address: [fd00:1122:3344:103::1]:12345
usable hw threads: 10
CPU family: amd_milan
usable memory (GiB): 0
reservoir (GiB): 0
physical disks:
Expand Down Expand Up @@ -1319,6 +1321,7 @@ sled 89d02b1b-478c-401a-8e28-7a26f74fa41b (role = Gimlet, serial serial0)
found at: <REDACTED_TIMESTAMP> from fake sled agent
address: [fd00:1122:3344:101::1]:12345
usable hw threads: 10
CPU family: amd_milan
usable memory (GiB): 0
reservoir (GiB): 0
physical disks:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ sled 2b8f0cb3-0295-4b3c-bc58-4fe88b57112c (role = Gimlet, serial serial1)
found at: <REDACTED_TIMESTAMP> from fake sled agent
address: [fd00:1122:3344:102::1]:12345
usable hw threads: 10
CPU family: amd_milan
usable memory (GiB): 0
reservoir (GiB): 0
physical disks:
Expand Down Expand Up @@ -194,6 +195,7 @@ sled 98e6b7c2-2efa-41ca-b20a-0a4d61102fe6 (role = Gimlet, serial serial0)
found at: <REDACTED_TIMESTAMP> from fake sled agent
address: [fd00:1122:3344:101::1]:12345
usable hw threads: 10
CPU family: amd_milan
usable memory (GiB): 0
reservoir (GiB): 0
physical disks:
Expand Down Expand Up @@ -302,6 +304,7 @@ sled d81c6a84-79b8-4958-ae41-ea46c9b19763 (role = Gimlet, serial serial2)
found at: <REDACTED_TIMESTAMP> from fake sled agent
address: [fd00:1122:3344:103::1]:12345
usable hw threads: 10
CPU family: amd_milan
usable memory (GiB): 0
reservoir (GiB): 0
physical disks:
Expand Down
5 changes: 3 additions & 2 deletions nexus-sled-agent-shared/src/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ use omicron_uuid_kinds::{SledUuid, ZpoolUuid};
use schemars::schema::{Schema, SchemaObject};
use schemars::{JsonSchema, SchemaGenerator};
use serde::{Deserialize, Serialize};
// Export this type for convenience -- this way, dependents don't have to
// Export these types for convenience -- this way, dependents don't have to
// depend on sled-hardware-types.
pub use sled_hardware_types::Baseboard;
pub use sled_hardware_types::{Baseboard, SledCpuFamily};
use strum::EnumIter;
use tufaceous_artifact::{ArtifactHash, KnownArtifactKind};

Expand Down Expand Up @@ -121,6 +121,7 @@ pub struct Inventory {
pub baseboard: Baseboard,
pub usable_hardware_threads: u32,
pub usable_physical_ram: ByteCount,
pub cpu_family: SledCpuFamily,
pub reservoir_size: ByteCount,
pub disks: Vec<InventoryDisk>,
pub zpools: Vec<InventoryZpool>,
Expand Down
3 changes: 3 additions & 0 deletions nexus/db-model/src/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::ArtifactHash;
use crate::Generation;
use crate::PhysicalDiskKind;
use crate::omicron_zone_config::{self, OmicronZoneNic};
use crate::sled_cpu_family::SledCpuFamily;
use crate::typed_uuid::DbTypedUuid;
use crate::{
ByteCount, MacAddr, Name, ServiceKind, SqlU8, SqlU16, SqlU32,
Expand Down Expand Up @@ -887,6 +888,7 @@ pub struct InvSledAgent {
pub sled_role: SledRole,
pub usable_hardware_threads: SqlU32,
pub usable_physical_ram: ByteCount,
pub cpu_family: SledCpuFamily,
pub reservoir_size: ByteCount,
// Soft foreign key to an `InvOmicronSledConfig`
pub ledgered_sled_config: Option<DbTypedUuid<OmicronSledConfigKind>>,
Expand Down Expand Up @@ -1300,6 +1302,7 @@ impl InvSledAgent {
usable_physical_ram: ByteCount::from(
sled_agent.usable_physical_ram,
),
cpu_family: sled_agent.cpu_family.into(),
reservoir_size: ByteCount::from(sled_agent.reservoir_size),
ledgered_sled_config: ledgered_sled_config.map(From::from),
reconciler_status,
Expand Down
2 changes: 2 additions & 0 deletions nexus/db-model/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ mod silo_group;
mod silo_user;
mod silo_user_password_hash;
mod sled;
mod sled_cpu_family;
mod sled_instance;
mod sled_policy;
mod sled_resource_vmm;
Expand Down Expand Up @@ -223,6 +224,7 @@ pub use silo_group::*;
pub use silo_user::*;
pub use silo_user_password_hash::*;
pub use sled::*;
pub use sled_cpu_family::*;
pub use sled_instance::*;
pub use sled_policy::to_db_sled_policy; // Do not expose DbSledPolicy
pub use sled_resource_vmm::*;
Expand Down
3 changes: 2 additions & 1 deletion nexus/db-model/src/schema_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::{collections::BTreeMap, sync::LazyLock};
///
/// This must be updated when you change the database schema. Refer to
/// schema/crdb/README.adoc in the root of this repository for details.
pub const SCHEMA_VERSION: Version = Version::new(173, 0, 0);
pub const SCHEMA_VERSION: Version = Version::new(174, 0, 0);

/// List of all past database schema versions, in *reverse* order
///
Expand All @@ -28,6 +28,7 @@ static KNOWN_VERSIONS: LazyLock<Vec<KnownVersion>> = LazyLock::new(|| {
// | leaving the first copy as an example for the next person.
// v
// KnownVersion::new(next_int, "unique-dirname-with-the-sql-files"),
KnownVersion::new(174, "sled-cpu-family"),
KnownVersion::new(173, "inv-internal-dns"),
KnownVersion::new(172, "add-zones-with-mupdate-override"),
KnownVersion::new(171, "inv-clear-mupdate-override"),
Expand Down
18 changes: 18 additions & 0 deletions nexus/db-model/src/sled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use super::{ByteCount, Generation, SledState, SqlU16, SqlU32};
use crate::collection::DatastoreCollectionConfig;
use crate::ipv6;
use crate::sled::shared::Baseboard;
use crate::sled_cpu_family::SledCpuFamily;
use crate::sled_policy::DbSledPolicy;
use chrono::{DateTime, Utc};
use db_macros::Asset;
Expand Down Expand Up @@ -40,6 +41,8 @@ pub struct SledSystemHardware {

// current VMM reservoir size
pub reservoir_size: ByteCount,

pub cpu_family: SledCpuFamily,
}

/// Database representation of a Sled.
Expand Down Expand Up @@ -84,6 +87,16 @@ pub struct Sled {

// ServiceAddress (Repo Depot API). Uses `ip`.
pub repo_depot_port: SqlU16,

/// The family of this sled's CPU.
///
/// This is primarily useful for questions about instance CPU platform
/// compatibility; it is too broad for topology-related sled selection
/// and more precise than a more general report of microarchitecture. We
/// likely should include much more about the sled's CPU alongside this for
/// those broader questions and reporting (see
/// <https://github.com/oxidecomputer/omicron/issues/8730> for examples).
pub cpu_family: SledCpuFamily,
}

impl Sled {
Expand Down Expand Up @@ -185,6 +198,7 @@ impl From<Sled> for params::SledAgentInfo {
usable_physical_ram: sled.usable_physical_ram.into(),
reservoir_size: sled.reservoir_size.into(),
generation: sled.sled_agent_gen.into(),
cpu_family: sled.cpu_family.into(),
decommissioned,
}
}
Expand Down Expand Up @@ -229,6 +243,8 @@ pub struct SledUpdate {
// ServiceAddress (Repo Depot API). Uses `ip`.
pub repo_depot_port: SqlU16,

pub cpu_family: SledCpuFamily,

// Generation number - owned and incremented by sled-agent.
pub sled_agent_gen: Generation,
}
Expand Down Expand Up @@ -258,6 +274,7 @@ impl SledUpdate {
ip: addr.ip().into(),
port: addr.port().into(),
repo_depot_port: repo_depot_port.into(),
cpu_family: hardware.cpu_family,
sled_agent_gen,
}
}
Expand Down Expand Up @@ -296,6 +313,7 @@ impl SledUpdate {
repo_depot_port: self.repo_depot_port,
last_used_address,
sled_agent_gen: self.sled_agent_gen,
cpu_family: self.cpu_family,
}
}

Expand Down
50 changes: 50 additions & 0 deletions nexus/db-model/src/sled_cpu_family.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use super::impl_enum_type;
use serde::{Deserialize, Serialize};

impl_enum_type!(
SledCpuFamilyEnum:

#[derive(
Copy,
Clone,
Debug,
PartialEq,
AsExpression,
FromSqlRow,
Serialize,
Deserialize
)]
pub enum SledCpuFamily;

Unknown => b"unknown"
AmdMilan => b"amd_milan"
AmdTurin => b"amd_turin"
AmdTurinDense => b"amd_turin_dense"
);

impl From<nexus_sled_agent_shared::inventory::SledCpuFamily> for SledCpuFamily {
fn from(value: nexus_sled_agent_shared::inventory::SledCpuFamily) -> Self {
use nexus_sled_agent_shared::inventory::SledCpuFamily as InputFamily;
match value {
InputFamily::Unknown => Self::Unknown,
InputFamily::AmdMilan => Self::AmdMilan,
InputFamily::AmdTurin => Self::AmdTurin,
InputFamily::AmdTurinDense => Self::AmdTurinDense,
}
}
}

impl From<SledCpuFamily> for nexus_sled_agent_shared::inventory::SledCpuFamily {
fn from(value: SledCpuFamily) -> Self {
match value {
SledCpuFamily::Unknown => Self::Unknown,
SledCpuFamily::AmdMilan => Self::AmdMilan,
SledCpuFamily::AmdTurin => Self::AmdTurin,
SledCpuFamily::AmdTurinDense => Self::AmdTurinDense,
}
}
}
2 changes: 2 additions & 0 deletions nexus/db-queries/src/db/datastore/crucible_dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ mod test {
use crate::db::pub_test_utils::TestDatabase;
use nexus_db_model::Generation;
use nexus_db_model::SledBaseboard;
use nexus_db_model::SledCpuFamily;
use nexus_db_model::SledSystemHardware;
use nexus_db_model::SledUpdate;
use omicron_common::api::external::ByteCount;
Expand Down Expand Up @@ -323,6 +324,7 @@ mod test {
usable_hardware_threads: 128,
usable_physical_ram: (64 << 30).try_into().unwrap(),
reservoir_size: (16 << 30).try_into().unwrap(),
cpu_family: SledCpuFamily::AmdMilan,
},
Uuid::new_v4(),
Generation::new(),
Expand Down
5 changes: 5 additions & 0 deletions nexus/db-queries/src/db/datastore/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,8 @@ impl DataStore {
sled_agent.usable_physical_ram,
)
.into_sql::<diesel::sql_types::Int8>(),
nexus_db_model::SledCpuFamily::from(sled_agent.cpu_family)
.into_sql::<nexus_db_schema::enums::SledCpuFamilyEnum>(),
nexus_db_model::ByteCount::from(
sled_agent.reservoir_size,
)
Expand Down Expand Up @@ -1439,6 +1441,7 @@ impl DataStore {
sa_dsl::sled_role,
sa_dsl::usable_hardware_threads,
sa_dsl::usable_physical_ram,
sa_dsl::cpu_family,
sa_dsl::reservoir_size,
sa_dsl::ledgered_sled_config,
sa_dsl::reconciler_status_kind,
Expand Down Expand Up @@ -1470,6 +1473,7 @@ impl DataStore {
_sled_role,
_usable_hardware_threads,
_usable_physical_ram,
_cpu_family,
_reservoir_size,
_ledgered_sled_config,
_reconciler_status_kind,
Expand Down Expand Up @@ -3846,6 +3850,7 @@ impl DataStore {
sled_role: s.sled_role.into(),
usable_hardware_threads: u32::from(s.usable_hardware_threads),
usable_physical_ram: s.usable_physical_ram.into(),
cpu_family: s.cpu_family.into(),
reservoir_size: s.reservoir_size.into(),
// For disks, zpools, and datasets, the map for a sled ID is
// only populated if there is at least one disk/zpool/dataset
Expand Down
3 changes: 2 additions & 1 deletion nexus/db-queries/src/db/datastore/physical_disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ mod test {
use nexus_db_lookup::LookupPath;
use nexus_sled_agent_shared::inventory::{
Baseboard, ConfigReconcilerInventoryStatus, Inventory, InventoryDisk,
SledRole, ZoneImageResolverInventory,
SledCpuFamily, SledRole, ZoneImageResolverInventory,
};
use nexus_types::identity::Asset;
use omicron_common::api::external::ByteCount;
Expand Down Expand Up @@ -693,6 +693,7 @@ mod test {
sled_id: SledUuid::from_untyped_uuid(sled.id()),
usable_hardware_threads: 10,
usable_physical_ram: ByteCount::from(1024 * 1024),
cpu_family: SledCpuFamily::AmdMilan,
disks,
zpools: vec![],
datasets: vec![],
Expand Down
1 change: 1 addition & 0 deletions nexus/db-queries/src/db/datastore/sled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ impl DataStore {
.eq(sled_update.usable_hardware_threads),
dsl::usable_physical_ram.eq(sled_update.usable_physical_ram),
dsl::reservoir_size.eq(sled_update.reservoir_size),
dsl::cpu_family.eq(sled_update.cpu_family),
dsl::sled_agent_gen.eq(sled_update.sled_agent_gen),
))
.filter(dsl::sled_agent_gen.lt(sled_update.sled_agent_gen))
Expand Down
2 changes: 2 additions & 0 deletions nexus/db-queries/src/db/datastore/support_bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ mod test {
use crate::db::pub_test_utils::TestDatabase;
use nexus_db_model::Generation;
use nexus_db_model::SledBaseboard;
use nexus_db_model::SledCpuFamily;
use nexus_db_model::SledSystemHardware;
use nexus_db_model::SledUpdate;
use nexus_db_model::Zpool;
Expand Down Expand Up @@ -617,6 +618,7 @@ mod test {
usable_hardware_threads: 128,
usable_physical_ram: (64 << 30).try_into().unwrap(),
reservoir_size: (16 << 30).try_into().unwrap(),
cpu_family: SledCpuFamily::AmdMilan,
},
rack_id,
Generation::new(),
Expand Down
9 changes: 9 additions & 0 deletions nexus/db-queries/src/db/pub_test_utils/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use nexus_db_model::ProjectImage;
use nexus_db_model::ProjectImageIdentity;
use nexus_db_model::Resources;
use nexus_db_model::SledBaseboard;
use nexus_db_model::SledCpuFamily;
use nexus_db_model::SledSystemHardware;
use nexus_db_model::SledUpdate;
use nexus_db_model::Snapshot;
Expand Down Expand Up @@ -77,6 +78,7 @@ pub struct SledSystemHardwareBuilder {
usable_hardware_threads: u32,
usable_physical_ram: i64,
reservoir_size: i64,
cpu_family: SledCpuFamily,
}

impl Default for SledSystemHardwareBuilder {
Expand All @@ -86,6 +88,7 @@ impl Default for SledSystemHardwareBuilder {
usable_hardware_threads: 4,
usable_physical_ram: 1 << 40,
reservoir_size: 1 << 39,
cpu_family: SledCpuFamily::AmdMilan,
}
}
}
Expand Down Expand Up @@ -121,12 +124,18 @@ impl SledSystemHardwareBuilder {
self
}

pub fn cpu_family(&mut self, family: SledCpuFamily) -> &mut Self {
self.cpu_family = family;
self
}

pub fn build(&self) -> SledSystemHardware {
SledSystemHardware {
is_scrimlet: self.is_scrimlet,
usable_hardware_threads: self.usable_hardware_threads,
usable_physical_ram: self.usable_physical_ram.try_into().unwrap(),
reservoir_size: self.reservoir_size.try_into().unwrap(),
cpu_family: self.cpu_family,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions nexus/db-schema/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ define_enums! {
RouterRouteKindEnum => "router_route_kind",
SagaStateEnum => "saga_state",
ServiceKindEnum => "service_kind",
SledCpuFamilyEnum => "sled_cpu_family",
SledPolicyEnum => "sled_policy",
SledRoleEnum => "sled_role",
SledStateEnum => "sled_state",
Expand Down
Loading
Loading