Skip to content

Commit

Permalink
Co-locate 'data' datasets with 'zone' datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
smklein committed Jan 16, 2024
1 parent 146aa5f commit 2dd40e7
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions sled-agent/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2887,12 +2887,10 @@ impl ServiceManager {
}

// Create zones that should be running
let all_u2_roots = self
.inner
.storage
.get_latest_resources()
.await
.all_u2_mountpoints(ZONE_DATASET);
let storage = self.inner.storage.get_latest_resources().await;
let all_u2_pools = storage.all_u2_zpools();
let all_u2_roots = storage.all_u2_mountpoints(ZONE_DATASET);

let mut new_zones = Vec::new();
for zone in zones_to_be_added {
// Check if we think the zone should already be running
Expand Down Expand Up @@ -2932,11 +2930,32 @@ impl ServiceManager {
//
// This is (currently) intentional, as the zone filesystem should
// be destroyed between reboots.
let mut rng = rand::thread_rng();
let root = all_u2_roots
.choose(&mut rng)
.ok_or_else(|| Error::U2NotFound)?
.clone();
let root = if let Some(dataset) = zone.dataset_name() {
// If the zone happens to already manage a dataset, then
// we co-locate the zone dataset on the same zpool.
//
// This slightly reduces the underlying fault domain for the
// service.
let data_pool = dataset.pool();
if !all_u2_pools.contains(&data_pool) {
warn!(
log,
"zone dataset requested on a zpool which doesn't exist";
"zone" => &name,
"zpool" => %data_pool
);
return Err(Error::MissingDevice {
device: format!("zpool: {data_pool}"),
});
}
data_pool.dataset_mountpoint(ZONE_DATASET)
} else {
let mut rng = rand::thread_rng();
all_u2_roots
.choose(&mut rng)
.ok_or_else(|| Error::U2NotFound)?
.clone()
};

new_zones.push(OmicronZoneConfigLocal { zone: zone.clone(), root });
}
Expand Down

0 comments on commit 2dd40e7

Please sign in to comment.