diff --git a/sled-agent/src/services.rs b/sled-agent/src/services.rs index 4396f77f37..9d660f2311 100644 --- a/sled-agent/src/services.rs +++ b/sled-agent/src/services.rs @@ -102,7 +102,7 @@ use sled_agent_types::{ sled::SWITCH_ZONE_BASEBOARD_FILE, time_sync::TimeSync, zone_bundle::ZoneBundleCause, }; -use sled_agent_zone_images::ZoneImageSourceResolver; +use sled_agent_zone_images::{ZoneImageSourceResolver, ZoneImageZpools}; use sled_hardware::SledMode; use sled_hardware::is_gimlet; use sled_hardware::underlay; @@ -1728,10 +1728,17 @@ impl ServiceManager { ZoneArgs::Switch(_) => &OmicronZoneImageSource::InstallDataset, }; let all_disks = self.inner.storage.get_latest_disks().await; - let file_source = self - .inner - .zone_image_resolver - .file_source_for(image_source, &all_disks); + let zpools = ZoneImageZpools { + root: &all_disks.mount_config().root, + all_m2_zpools: all_disks.all_m2_zpools(), + }; + let boot_zpool = + all_disks.boot_disk().map(|(_, boot_zpool)| boot_zpool); + let file_source = self.inner.zone_image_resolver.file_source_for( + image_source, + &zpools, + boot_zpool.as_ref(), + ); let zone_type_str = match &request { ZoneArgs::Omicron(zone_config) => { diff --git a/sled-agent/zone-images/src/source_resolver.rs b/sled-agent/zone-images/src/source_resolver.rs index 96621aca76..576e1676ad 100644 --- a/sled-agent/zone-images/src/source_resolver.rs +++ b/sled-agent/zone-images/src/source_resolver.rs @@ -11,7 +11,6 @@ use illumos_utils::zpool::ZpoolName; use nexus_sled_agent_shared::inventory::OmicronZoneImageSource; use sled_storage::dataset::INSTALL_DATASET; use sled_storage::dataset::M2_ARTIFACT_DATASET; -use sled_storage::resources::AllDisks; use slog::o; use std::sync::Arc; use std::sync::Mutex; @@ -76,10 +75,11 @@ impl ZoneImageSourceResolver { pub fn file_source_for( &self, image_source: &OmicronZoneImageSource, - all_disks: &AllDisks, + zpools: &ZoneImageZpools<'_>, + boot_zpool: Option<&ZpoolName>, ) -> ZoneImageFileSource { let inner = self.inner.lock().unwrap(); - inner.file_source_for(image_source, all_disks) + inner.file_source_for(image_source, zpools, boot_zpool) } } @@ -130,7 +130,8 @@ impl ResolverInner { fn file_source_for( &self, image_source: &OmicronZoneImageSource, - all_disks: &AllDisks, + zpools: &ZoneImageZpools<'_>, + boot_zpool: Option<&ZpoolName>, ) -> ZoneImageFileSource { let file_name = match image_source { OmicronZoneImageSource::InstallDataset => { @@ -151,32 +152,30 @@ impl ResolverInner { }; // If the boot disk exists, look for the image in the "install" - // dataset there too. - if let Some((_, boot_zpool)) = all_disks.boot_disk() { - zone_image_paths.push(boot_zpool.dataset_mountpoint( - &all_disks.mount_config().root, - INSTALL_DATASET, - )); + // dataset on the boot zpool. + if let Some(boot_zpool) = boot_zpool { + zone_image_paths.push( + boot_zpool + .dataset_mountpoint(zpools.root, INSTALL_DATASET), + ); } zone_image_paths } OmicronZoneImageSource::Artifact { .. } => { // Search both artifact datasets, but look on the boot disk first. - let boot_zpool = - all_disks.boot_disk().map(|(_, boot_zpool)| boot_zpool); // This iterator starts with the zpool for the boot disk (if it // exists), and then is followed by all other zpools. let zpool_iter = boot_zpool.into_iter().chain( - all_disks - .all_m2_zpools() - .into_iter() + zpools + .all_m2_zpools + .iter() .filter(|zpool| Some(zpool) != boot_zpool.as_ref()), ); zpool_iter .map(|zpool| { zpool.dataset_mountpoint( - &all_disks.mount_config().root, + zpools.root, M2_ARTIFACT_DATASET, ) })