Skip to content

[5/n] [sled-agent] use ZoneImageZpools for image lookup as well #8095

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

Draft
wants to merge 4 commits into
base: sunshowers/spr/main.sled-agent-use-zoneimagezpools-for-image-lookup-as-well
Choose a base branch
from
Draft
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
17 changes: 12 additions & 5 deletions sled-agent/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) => {
Expand Down
31 changes: 15 additions & 16 deletions sled-agent/zone-images/src/source_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -133,7 +133,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 => {
Expand All @@ -154,32 +155,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,
)
})
Expand Down
Loading