diff --git a/sled-storage/src/manager.rs b/sled-storage/src/manager.rs index 9e31568e00..901642badc 100644 --- a/sled-storage/src/manager.rs +++ b/sled-storage/src/manager.rs @@ -8,9 +8,7 @@ use std::collections::HashSet; use crate::config::MountConfig; use crate::dataset::{DatasetName, CONFIG_DATASET}; -use crate::disk::{ - OmicronPhysicalDiskConfig, OmicronPhysicalDisksConfig, RawDisk, -}; +use crate::disk::{OmicronPhysicalDisksConfig, RawDisk}; use crate::error::Error; use crate::resources::{AllDisks, DisksManagementResult, StorageResources}; use camino::Utf8PathBuf; @@ -589,91 +587,11 @@ impl StorageManager { self.resources.set_config(&ledger.data().disks); } else { info!(self.log, "KeyManager ready, but no ledger detected"); - let mut synthetic_config = - self.resources.get_config().values().cloned().collect(); - // TODO(https://github.com/oxidecomputer/omicron/issues/5328): Once - // we are confident that we have migrated to a world where this - // ledger is universally used, we should remove the following - // kludge. The sled agent should not need to "self-manage" anything! - let changed = self - .self_manage_disks_with_zpools(&mut synthetic_config) - .await?; - if !changed { - info!(self.log, "No disks to be automatically managed"); - return Ok(()); - } - info!(self.log, "auto-managed disks"; "count" => synthetic_config.len()); - self.resources.set_config(&synthetic_config); } Ok(()) } - // NOTE: What follows is an exceptional case: one where we have - // no record of "Control Plane Physical Disks", but we have zpools - // on our U.2s, and we want to use them regardless. - // - // THIS WOULD NORMALLY BE INCORRECT BEHAVIOR. In the future, these - // zpools will not be "automatically imported", and instead, we'll - // let Nexus decide whether or not to reformat the disks. - // - // However, because we are transitioning from "the set of disks / - // zpools is implicit" to a world where that set is explicit, this - // is a necessary transitional tool. - // - // Returns "true" if the synthetic_config has changed. - async fn self_manage_disks_with_zpools( - &mut self, - synthetic_config: &mut Vec, - ) -> Result { - let mut changed = false; - for (identity, disk) in self.resources.disks().values.iter() { - match disk { - crate::resources::ManagedDisk::Unmanaged(raw) => { - let zpool_path = match raw.u2_zpool_path() { - Ok(zpool_path) => zpool_path, - Err(err) => { - info!(self.log, "Cannot find zpool path"; "identity" => ?identity, "err" => ?err); - continue; - } - }; - - let zpool_name = - match sled_hardware::disk::check_if_zpool_exists( - &zpool_path, - ) { - Ok(zpool_name) => zpool_name, - Err(err) => { - info!(self.log, "Zpool does not exist"; "identity" => ?identity, "err" => ?err); - continue; - } - }; - - info!(self.log, "Found existing zpool on device without ledger"; - "identity" => ?identity, - "zpool" => ?zpool_name); - - // We found an unmanaged disk with a zpool, even though - // we have no prior record of a ledger of control-plane - // disks. - synthetic_config.push( - // These disks don't have a control-plane UUID -- - // report "nil" until they're overwritten with real - // values. - OmicronPhysicalDiskConfig { - identity: identity.clone(), - id: Uuid::nil(), - pool_id: zpool_name.id(), - }, - ); - changed = true; - } - _ => continue, - } - } - Ok(changed) - } - // Makes an U.2 disk managed by the control plane within [`StorageResources`]. async fn omicron_physical_disks_ensure( &mut self,