Skip to content

Commit

Permalink
[reconfigurator] Only place Crucible zones on provisionable zpools
Browse files Browse the repository at this point in the history
  • Loading branch information
smklein committed Apr 23, 2024
1 parent 46f2be6 commit 138a116
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nexus/reconfigurator/planning/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ impl<'a> Planner<'a> {
continue;
}

// Every zpool on the sled should have a Crucible zone on it.
// Every provisionable zpool on the sled should have a Crucible zone on it.
let mut ncrucibles_added = 0;
for zpool_id in sled_resources.zpools.keys() {
for zpool_id in sled_resources.provisionable_zpools() {
if self
.blueprint
.sled_ensure_zone_crucible(sled_id, *zpool_id)?
Expand Down
28 changes: 28 additions & 0 deletions nexus/types/src/deployment/planning_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ pub struct SledDisk {
pub state: PhysicalDiskState,
}

impl SledDisk {
fn provisionable(&self) -> bool {
match (self.policy, self.state) {
(PhysicalDiskPolicy::InService, PhysicalDiskState::Active) => true,
_ => false,
}
}
}

/// Filters that apply to disks.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum DiskFilter {
Expand Down Expand Up @@ -87,6 +96,25 @@ pub struct SledResources {
}

impl SledResources {
/// Returns if the zpool is provisionable (known, in-service, and active).
pub fn zpool_is_provisionable(&self, zpool: &ZpoolUuid) -> bool {
let Some(disk) = self.zpools.get(zpool) else { return false };
disk.provisionable()
}

/// Returns all in-service, active zpools
pub fn provisionable_zpools(
&self,
) -> impl Iterator<Item = &ZpoolUuid> + '_ {
self.zpools.iter().filter_map(|(zpool, disk)| {
if disk.provisionable() {
Some(zpool)
} else {
None
}
})
}

pub fn all_disks(
&self,
filter: DiskFilter,
Expand Down

0 comments on commit 138a116

Please sign in to comment.