storcon_cli: do not drain to undesirable nodes (#8027)

## Problem
The previous code would attempt to drain to unavailable or unschedulable
nodes.

## Summary of Changes
Remove such nodes from the list of nodes to fill.
This commit is contained in:
Vlad Lazar
2024-06-12 12:33:54 +01:00
committed by GitHub
parent f749437cec
commit 3099e1a787

View File

@@ -786,18 +786,15 @@ async fn main() -> anyhow::Result<()> {
anyhow::bail!("Drain requested for node which doesn't exist.")
}
let can_fill = node_to_fill_descs
.iter()
.filter(|desc| {
matches!(desc.availability, NodeAvailabilityWrapper::Active)
&& matches!(
desc.scheduling,
NodeSchedulingPolicy::Active | NodeSchedulingPolicy::Filling
)
})
.any(|_| true);
node_to_fill_descs.retain(|desc| {
matches!(desc.availability, NodeAvailabilityWrapper::Active)
&& matches!(
desc.scheduling,
NodeSchedulingPolicy::Active | NodeSchedulingPolicy::Filling
)
});
if !can_fill {
if node_to_fill_descs.is_empty() {
anyhow::bail!("There are no nodes to drain to")
}