Skip to content

Commit abc98f2

Browse files
authored
[5/n] [sled-agent] use ZoneImageZpools for image lookup as well (#8095)
`AllDisks` is going to go away with sled-agent reconciler work. Just pass in the required context explicitly.
1 parent 2054471 commit abc98f2

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

sled-agent/src/services.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ use sled_agent_types::{
102102
sled::SWITCH_ZONE_BASEBOARD_FILE, time_sync::TimeSync,
103103
zone_bundle::ZoneBundleCause,
104104
};
105-
use sled_agent_zone_images::ZoneImageSourceResolver;
105+
use sled_agent_zone_images::{ZoneImageSourceResolver, ZoneImageZpools};
106106
use sled_hardware::SledMode;
107107
use sled_hardware::is_gimlet;
108108
use sled_hardware::underlay;
@@ -1728,10 +1728,17 @@ impl ServiceManager {
17281728
ZoneArgs::Switch(_) => &OmicronZoneImageSource::InstallDataset,
17291729
};
17301730
let all_disks = self.inner.storage.get_latest_disks().await;
1731-
let file_source = self
1732-
.inner
1733-
.zone_image_resolver
1734-
.file_source_for(image_source, &all_disks);
1731+
let zpools = ZoneImageZpools {
1732+
root: &all_disks.mount_config().root,
1733+
all_m2_zpools: all_disks.all_m2_zpools(),
1734+
};
1735+
let boot_zpool =
1736+
all_disks.boot_disk().map(|(_, boot_zpool)| boot_zpool);
1737+
let file_source = self.inner.zone_image_resolver.file_source_for(
1738+
image_source,
1739+
&zpools,
1740+
boot_zpool.as_ref(),
1741+
);
17351742

17361743
let zone_type_str = match &request {
17371744
ZoneArgs::Omicron(zone_config) => {

sled-agent/zone-images/src/source_resolver.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use illumos_utils::zpool::ZpoolName;
1111
use nexus_sled_agent_shared::inventory::OmicronZoneImageSource;
1212
use sled_storage::dataset::INSTALL_DATASET;
1313
use sled_storage::dataset::M2_ARTIFACT_DATASET;
14-
use sled_storage::resources::AllDisks;
1514
use slog::o;
1615
use std::sync::Arc;
1716
use std::sync::Mutex;
@@ -76,10 +75,11 @@ impl ZoneImageSourceResolver {
7675
pub fn file_source_for(
7776
&self,
7877
image_source: &OmicronZoneImageSource,
79-
all_disks: &AllDisks,
78+
zpools: &ZoneImageZpools<'_>,
79+
boot_zpool: Option<&ZpoolName>,
8080
) -> ZoneImageFileSource {
8181
let inner = self.inner.lock().unwrap();
82-
inner.file_source_for(image_source, all_disks)
82+
inner.file_source_for(image_source, zpools, boot_zpool)
8383
}
8484
}
8585

@@ -130,7 +130,8 @@ impl ResolverInner {
130130
fn file_source_for(
131131
&self,
132132
image_source: &OmicronZoneImageSource,
133-
all_disks: &AllDisks,
133+
zpools: &ZoneImageZpools<'_>,
134+
boot_zpool: Option<&ZpoolName>,
134135
) -> ZoneImageFileSource {
135136
let file_name = match image_source {
136137
OmicronZoneImageSource::InstallDataset => {
@@ -151,32 +152,30 @@ impl ResolverInner {
151152
};
152153

153154
// If the boot disk exists, look for the image in the "install"
154-
// dataset there too.
155-
if let Some((_, boot_zpool)) = all_disks.boot_disk() {
156-
zone_image_paths.push(boot_zpool.dataset_mountpoint(
157-
&all_disks.mount_config().root,
158-
INSTALL_DATASET,
159-
));
155+
// dataset on the boot zpool.
156+
if let Some(boot_zpool) = boot_zpool {
157+
zone_image_paths.push(
158+
boot_zpool
159+
.dataset_mountpoint(zpools.root, INSTALL_DATASET),
160+
);
160161
}
161162

162163
zone_image_paths
163164
}
164165
OmicronZoneImageSource::Artifact { .. } => {
165166
// Search both artifact datasets, but look on the boot disk first.
166-
let boot_zpool =
167-
all_disks.boot_disk().map(|(_, boot_zpool)| boot_zpool);
168167
// This iterator starts with the zpool for the boot disk (if it
169168
// exists), and then is followed by all other zpools.
170169
let zpool_iter = boot_zpool.into_iter().chain(
171-
all_disks
172-
.all_m2_zpools()
173-
.into_iter()
170+
zpools
171+
.all_m2_zpools
172+
.iter()
174173
.filter(|zpool| Some(zpool) != boot_zpool.as_ref()),
175174
);
176175
zpool_iter
177176
.map(|zpool| {
178177
zpool.dataset_mountpoint(
179-
&all_disks.mount_config().root,
178+
zpools.root,
180179
M2_ARTIFACT_DATASET,
181180
)
182181
})

0 commit comments

Comments
 (0)