diff --git a/clients/sled-agent-client/src/lib.rs b/clients/sled-agent-client/src/lib.rs index 6db8650ea30..d6ef32ec1a3 100644 --- a/clients/sled-agent-client/src/lib.rs +++ b/clients/sled-agent-client/src/lib.rs @@ -88,7 +88,6 @@ progenitor::generate_api!( NetworkInterfaceKind = sled_agent_types_versions::latest::inventory::NetworkInterfaceKind, Nonce = sled_agent_types_versions::latest::rot::Nonce, OmicronPhysicalDiskConfig = omicron_common::disk::OmicronPhysicalDiskConfig, - OmicronPhysicalDisksConfig = omicron_common::disk::OmicronPhysicalDisksConfig, OmicronSledConfig = sled_agent_types_versions::latest::inventory::OmicronSledConfig, OmicronZoneConfig = sled_agent_types_versions::latest::inventory::OmicronZoneConfig, OmicronZoneDataset = sled_agent_types_versions::latest::inventory::OmicronZoneDataset, diff --git a/common/src/disk.rs b/common/src/disk.rs index ebb072fa2fd..fe2d3fe02e7 100644 --- a/common/src/disk.rs +++ b/common/src/disk.rs @@ -14,16 +14,14 @@ use omicron_uuid_kinds::PhysicalDiskUuid; use omicron_uuid_kinds::ZpoolUuid; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use std::collections::BTreeMap; use std::fmt; use std::str::FromStr; use crate::api::internal::shared::DatasetKindParseError; use crate::{ - api::external::{ByteCount, Generation}, + api::external::ByteCount, zpool_name::{ZpoolKind, ZpoolName}, }; -use omicron_ledger::Ledgerable; pub use crate::api::internal::shared::DatasetKind; @@ -55,44 +53,6 @@ impl IdOrdItem for OmicronPhysicalDiskConfig { id_upcast!(); } -#[derive( - Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq, Eq, Hash, -)] -pub struct OmicronPhysicalDisksConfig { - /// generation number of this configuration - /// - /// This generation number is owned by the control plane (i.e., RSS or - /// Nexus, depending on whether RSS-to-Nexus handoff has happened). It - /// should not be bumped within Sled Agent. - /// - /// Sled Agent rejects attempts to set the configuration to a generation - /// older than the one it's currently running. - pub generation: Generation, - - pub disks: Vec, -} - -impl Default for OmicronPhysicalDisksConfig { - fn default() -> Self { - Self { generation: Generation::new(), disks: vec![] } - } -} - -impl Ledgerable for OmicronPhysicalDisksConfig { - fn is_newer_than(&self, other: &OmicronPhysicalDisksConfig) -> bool { - self.generation > other.generation - } - - // No need to do this, the generation number is provided externally. - fn generation_bump(&mut self) {} -} - -impl OmicronPhysicalDisksConfig { - pub fn new() -> Self { - Self { generation: Generation::new(), disks: vec![] } - } -} - #[derive( Debug, PartialEq, @@ -423,42 +383,6 @@ impl IdOrdItem for DatasetConfig { id_upcast!(); } -#[derive( - Clone, Debug, Deserialize, Serialize, JsonSchema, PartialEq, Eq, Hash, -)] -pub struct DatasetsConfig { - /// generation number of this configuration - /// - /// This generation number is owned by the control plane (i.e., RSS or - /// Nexus, depending on whether RSS-to-Nexus handoff has happened). It - /// should not be bumped within Sled Agent. - /// - /// Sled Agent rejects attempts to set the configuration to a generation - /// older than the one it's currently running. - /// - /// Note that "Generation::new()", AKA, the first generation number, - /// is reserved for "no datasets". This is the default configuration - /// for a sled before any requests have been made. - pub generation: Generation, - - pub datasets: BTreeMap, -} - -impl Default for DatasetsConfig { - fn default() -> Self { - Self { generation: Generation::new(), datasets: BTreeMap::new() } - } -} - -impl Ledgerable for DatasetsConfig { - fn is_newer_than(&self, other: &Self) -> bool { - self.generation > other.generation - } - - // No need to do this, the generation number is provided externally. - fn generation_bump(&mut self) {} -} - /// Uniquely identifies a disk. #[derive( Debug, diff --git a/schema/omicron-datasets.json b/schema/omicron-datasets.json deleted file mode 100644 index b16bc1ed231..00000000000 --- a/schema/omicron-datasets.json +++ /dev/null @@ -1,241 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "DatasetsConfig", - "type": "object", - "required": [ - "datasets", - "generation" - ], - "properties": { - "datasets": { - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/DatasetConfig" - } - }, - "generation": { - "description": "generation number of this configuration\n\nThis generation number is owned by the control plane (i.e., RSS or Nexus, depending on whether RSS-to-Nexus handoff has happened). It should not be bumped within Sled Agent.\n\nSled Agent rejects attempts to set the configuration to a generation older than the one it's currently running.\n\nNote that \"Generation::new()\", AKA, the first generation number, is reserved for \"no datasets\". This is the default configuration for a sled before any requests have been made.", - "allOf": [ - { - "$ref": "#/definitions/Generation" - } - ] - } - }, - "definitions": { - "ByteCount": { - "description": "Byte count to express memory or storage capacity.", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "CompressionAlgorithm": { - "oneOf": [ - { - "type": "object", - "required": [ - "type" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "on" - ] - } - } - }, - { - "type": "object", - "required": [ - "type" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "off" - ] - } - } - }, - { - "type": "object", - "required": [ - "type" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "gzip" - ] - } - } - }, - { - "type": "object", - "required": [ - "level", - "type" - ], - "properties": { - "level": { - "$ref": "#/definitions/GzipLevel" - }, - "type": { - "type": "string", - "enum": [ - "gzip_n" - ] - } - } - }, - { - "type": "object", - "required": [ - "type" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "lz4" - ] - } - } - }, - { - "type": "object", - "required": [ - "type" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "lzjb" - ] - } - } - }, - { - "type": "object", - "required": [ - "type" - ], - "properties": { - "type": { - "type": "string", - "enum": [ - "zle" - ] - } - } - } - ] - }, - "DatasetConfig": { - "description": "Configuration information necessary to request a single dataset.\n\nThese datasets are tracked directly by Nexus.", - "type": "object", - "required": [ - "compression", - "id", - "name" - ], - "properties": { - "compression": { - "description": "The compression mode to be used by the dataset", - "allOf": [ - { - "$ref": "#/definitions/CompressionAlgorithm" - } - ] - }, - "id": { - "description": "The UUID of the dataset being requested", - "allOf": [ - { - "$ref": "#/definitions/DatasetUuid" - } - ] - }, - "name": { - "description": "The dataset's name", - "allOf": [ - { - "$ref": "#/definitions/DatasetName" - } - ] - }, - "quota": { - "description": "The upper bound on the amount of storage used by this dataset", - "anyOf": [ - { - "$ref": "#/definitions/ByteCount" - }, - { - "type": "null" - } - ] - }, - "reservation": { - "description": "The lower bound on the amount of storage usable by this dataset", - "anyOf": [ - { - "$ref": "#/definitions/ByteCount" - }, - { - "type": "null" - } - ] - } - } - }, - "DatasetKind": { - "description": "The kind of dataset. See the `DatasetKind` enum in omicron-common for possible values.", - "type": "string" - }, - "DatasetName": { - "type": "object", - "required": [ - "kind", - "pool_name" - ], - "properties": { - "kind": { - "$ref": "#/definitions/DatasetKind" - }, - "pool_name": { - "$ref": "#/definitions/ZpoolName" - } - } - }, - "DatasetUuid": { - "type": "string", - "format": "uuid", - "x-rust-type": { - "crate": "omicron-uuid-kinds", - "path": "omicron_uuid_kinds::DatasetUuid", - "version": "*" - } - }, - "Generation": { - "description": "Generation numbers stored in the database, used for optimistic concurrency control", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "GzipLevel": { - "type": "integer", - "format": "uint8", - "minimum": 0.0 - }, - "ZpoolName": { - "title": "The name of a Zpool", - "description": "Zpool names are of the format ox{i,p}_. They are either Internal or External, and should be unique", - "type": "string", - "pattern": "^ox[ip]_[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$" - } - } -} \ No newline at end of file diff --git a/schema/omicron-physical-disks.json b/schema/omicron-physical-disks.json deleted file mode 100644 index 7c301af7906..00000000000 --- a/schema/omicron-physical-disks.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "OmicronPhysicalDisksConfig", - "type": "object", - "required": [ - "disks", - "generation" - ], - "properties": { - "disks": { - "type": "array", - "items": { - "$ref": "#/definitions/OmicronPhysicalDiskConfig" - } - }, - "generation": { - "description": "generation number of this configuration\n\nThis generation number is owned by the control plane (i.e., RSS or Nexus, depending on whether RSS-to-Nexus handoff has happened). It should not be bumped within Sled Agent.\n\nSled Agent rejects attempts to set the configuration to a generation older than the one it's currently running.", - "allOf": [ - { - "$ref": "#/definitions/Generation" - } - ] - } - }, - "definitions": { - "DiskIdentity": { - "description": "Uniquely identifies a disk.", - "type": "object", - "required": [ - "model", - "serial", - "vendor" - ], - "properties": { - "model": { - "type": "string" - }, - "serial": { - "type": "string" - }, - "vendor": { - "type": "string" - } - } - }, - "Generation": { - "description": "Generation numbers stored in the database, used for optimistic concurrency control", - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, - "OmicronPhysicalDiskConfig": { - "type": "object", - "required": [ - "id", - "identity", - "pool_id" - ], - "properties": { - "id": { - "$ref": "#/definitions/PhysicalDiskUuid" - }, - "identity": { - "$ref": "#/definitions/DiskIdentity" - }, - "pool_id": { - "$ref": "#/definitions/ZpoolUuid" - } - } - }, - "PhysicalDiskUuid": { - "type": "string", - "format": "uuid", - "x-rust-type": { - "crate": "omicron-uuid-kinds", - "path": "omicron_uuid_kinds::PhysicalDiskUuid", - "version": "*" - } - }, - "ZpoolUuid": { - "type": "string", - "format": "uuid", - "x-rust-type": { - "crate": "omicron-uuid-kinds", - "path": "omicron_uuid_kinds::ZpoolUuid", - "version": "*" - } - } - } -} \ No newline at end of file diff --git a/sled-agent/src/sim/server.rs b/sled-agent/src/sim/server.rs index 2ac124176dc..4e8246c1d28 100644 --- a/sled-agent/src/sim/server.rs +++ b/sled-agent/src/sim/server.rs @@ -585,8 +585,8 @@ pub async fn run_standalone_server( }; let blueprint = { - let omicron_physical_disks_config = - server.sled_agent.omicron_physical_disks_list()?; + let sled_config = + server.sled_agent.omicron_sled_config().unwrap_or_default(); let underlay_address = match server.http_server.local_addr() { SocketAddr::V4(_) => { bail!("sled_agent_ip must be v6") @@ -613,7 +613,7 @@ pub async fn run_standalone_server( subnet, last_allocated_ip_subnet_offset, config: SledConfig { - disks: omicron_physical_disks_config + disks: sled_config .disks .into_iter() .map(|config| BlueprintPhysicalDiskConfig { @@ -624,7 +624,11 @@ pub async fn run_standalone_server( pool_id: config.pool_id, }) .collect(), - datasets: server.sled_agent.datasets_config_list()?.datasets, + datasets: sled_config + .datasets + .into_iter() + .map(|config| (config.id, config)) + .collect(), zones, }, }); diff --git a/sled-agent/src/sim/sled_agent.rs b/sled-agent/src/sim/sled_agent.rs index 363be251708..81d6b7fc8ad 100644 --- a/sled-agent/src/sim/sled_agent.rs +++ b/sled-agent/src/sim/sled_agent.rs @@ -33,9 +33,7 @@ use omicron_common::api::internal::shared::{ ResolvedVpcRoute, ResolvedVpcRouteSet, ResolvedVpcRouteState, RouterId, RouterKind, RouterVersion, VirtualNetworkInterfaceHost, }; -use omicron_common::disk::{ - DatasetsConfig, DiskIdentity, DiskVariant, OmicronPhysicalDisksConfig, -}; +use omicron_common::disk::{DiskIdentity, DiskVariant}; use omicron_uuid_kinds::{ DatasetUuid, GenericUuid, PhysicalDiskUuid, PropolisUuid, SledUuid, SupportBundleUuid, ZpoolUuid, @@ -1081,16 +1079,6 @@ impl SledAgent { .map_err(|err| err.into()) } - pub fn datasets_config_list(&self) -> Result { - self.storage.lock().datasets_config_list() - } - - pub fn omicron_physical_disks_list( - &self, - ) -> Result { - self.storage.lock().omicron_physical_disks_list() - } - pub fn set_omicron_config( &self, config: OmicronSledConfig, diff --git a/sled-agent/src/sim/storage.rs b/sled-agent/src/sim/storage.rs index 92af5dd8608..e7e0b9df978 100644 --- a/sled-agent/src/sim/storage.rs +++ b/sled-agent/src/sim/storage.rs @@ -25,10 +25,8 @@ use dropshot::HttpError; use illumos_utils::zfs::DatasetProperties; use omicron_common::api::external::ByteCount; use omicron_common::disk::DatasetName; -use omicron_common::disk::DatasetsConfig; use omicron_common::disk::DiskIdentity; use omicron_common::disk::DiskVariant; -use omicron_common::disk::OmicronPhysicalDisksConfig; use omicron_common::disk::SharedDatasetConfig; use omicron_uuid_kinds::DatasetUuid; use omicron_uuid_kinds::ExternalZpoolUuid; @@ -1444,23 +1442,6 @@ impl StorageInner { self.sled_config.clone() } - pub fn datasets_config_list(&self) -> Result { - let Some(config) = self.sled_config.as_ref() else { - return Err(HttpError::for_not_found( - None, - "No control plane datasets".into(), - )); - }; - Ok(DatasetsConfig { - generation: config.generation, - datasets: config - .datasets - .iter() - .map(|dataset| (dataset.id, dataset.clone())) - .collect(), - }) - } - pub fn dataset_get( &self, dataset_name: &String, @@ -1720,21 +1701,6 @@ impl StorageInner { )); } - pub fn omicron_physical_disks_list( - &self, - ) -> Result { - let Some(config) = self.sled_config.as_ref() else { - return Err(HttpError::for_not_found( - None, - "No control plane disks".into(), - )); - }; - Ok(OmicronPhysicalDisksConfig { - generation: config.generation, - disks: config.disks.iter().cloned().collect(), - }) - } - pub fn insert_physical_disk( &mut self, id: PhysicalDiskUuid, diff --git a/sled-agent/src/support_bundle/storage.rs b/sled-agent/src/support_bundle/storage.rs index a06406166ed..29ad62aeb42 100644 --- a/sled-agent/src/support_bundle/storage.rs +++ b/sled-agent/src/support_bundle/storage.rs @@ -296,7 +296,13 @@ impl LocalStorage for sim::Storage { // This gives us a local clone of the datasets config; we call // `remove(dataset_id)` below to avoid having to also clone the dataset // config we want to return. - let mut config = self.lock().datasets_config_list()?; + // + // TODO-cleanup Why do we return an HTTP "not found" in one case and a + // separate `DatasetNotFound` in the other case? We have a test that + // cares about the difference. + let mut config = self.lock().omicron_sled_config().ok_or( + HttpError::for_not_found(None, "No control plane datasets".into()), + )?; config.datasets.remove(dataset_id).ok_or(Error::DatasetNotFound) }