|
1 |
| -use crate::controller::scheduling::{ |
2 |
| - resources::{ChildItem, PoolItem}, |
3 |
| - volume::{GetSuitablePoolsContext, ReplicaResizePoolsContext}, |
4 |
| - volume_policy::qualifies_label_criteria, |
| 1 | +use crate::controller::{ |
| 2 | + registry::Registry, |
| 3 | + scheduling::{ |
| 4 | + resources::{ChildItem, PoolItem}, |
| 5 | + volume::{GetSuitablePoolsContext, ReplicaResizePoolsContext}, |
| 6 | + volume_policy::qualifies_label_criteria, |
| 7 | + }, |
5 | 8 | };
|
6 | 9 | use std::collections::HashMap;
|
7 |
| -use stor_port::types::v0::transport::{PoolStatus, PoolTopology}; |
| 10 | +use stor_port::types::v0::{ |
| 11 | + store::volume::VolumeSpec, |
| 12 | + transport::{PoolId, PoolStatus, PoolTopology}, |
| 13 | +}; |
8 | 14 |
|
9 | 15 | /// Filter pools used for replica creation.
|
10 | 16 | pub(crate) struct PoolBaseFilters {}
|
@@ -77,27 +83,32 @@ impl PoolBaseFilters {
|
77 | 83 |
|
78 | 84 | /// Should only attempt to use pools having specific creation label if topology has it.
|
79 | 85 | pub(crate) fn topology(request: &GetSuitablePoolsContext, item: &PoolItem) -> bool {
|
| 86 | + Self::topology_(request, request.registry(), &item.pool.id) |
| 87 | + } |
| 88 | + |
| 89 | + /// Should only attempt to use pools having specific creation label if topology has it. |
| 90 | + pub(crate) fn topology_(volume: &VolumeSpec, registry: &Registry, pool_id: &PoolId) -> bool { |
80 | 91 | let volume_pool_topology_inclusion_labels: HashMap<String, String>;
|
81 |
| - match request.topology.clone() { |
| 92 | + match &volume.topology { |
82 | 93 | None => return true,
|
83 |
| - Some(topology) => match topology.pool { |
| 94 | + Some(topology) => match &topology.pool { |
84 | 95 | None => return true,
|
85 |
| - Some(pool_topology) => match pool_topology { |
| 96 | + Some(pool_topology) => match &pool_topology { |
86 | 97 | PoolTopology::Labelled(labelled_topology) => {
|
87 | 98 | // The labels in Volume Pool Topology should match the pool labels if
|
88 | 99 | // present, otherwise selection of any pool is allowed.
|
89 |
| - if !labelled_topology.inclusion.is_empty() { |
90 |
| - volume_pool_topology_inclusion_labels = labelled_topology.inclusion |
91 |
| - } else { |
| 100 | + if labelled_topology.inclusion.is_empty() { |
| 101 | + // todo: missing exclusion check? |
92 | 102 | return true;
|
93 | 103 | }
|
| 104 | + volume_pool_topology_inclusion_labels = labelled_topology.inclusion.clone() |
94 | 105 | }
|
95 | 106 | },
|
96 | 107 | },
|
97 | 108 | };
|
98 | 109 |
|
99 | 110 | // We will reach this part of code only if the volume has inclusion/exclusion labels.
|
100 |
| - match request.registry().specs().pool(&item.pool.id) { |
| 111 | + match registry.specs().pool(pool_id) { |
101 | 112 | Ok(spec) => match spec.labels {
|
102 | 113 | None => false,
|
103 | 114 | Some(pool_labels) => {
|
|
0 commit comments