@@ -2009,60 +2009,53 @@ private List<StoragePool> findAllSuitableStoragePoolsForDetachedVolume(Volume vo
20092009 logger .debug ("Finding suitable pools for detached volume {} with offering tags: {}, hypervisor: {}" ,
20102010 volume .getUuid (), tags , hypervisorType );
20112011
2012- // Create a map for quick lookup and deduplication
2013- Map <Long , StoragePool > allPoolsMap = allPools .stream ()
2014- .collect (Collectors .toMap (StoragePool ::getId , pool -> pool ));
20152012 Set <Long > matchingPoolIds = new HashSet <>();
20162013
2017- List <StoragePoolVO > zonePoolsLiteral = _poolDao .findZoneWideStoragePoolsByTags (dcId ,
2014+ List <StoragePoolVO > zonePoolsStandard = _poolDao .findZoneWideStoragePoolsByTags (dcId ,
20182015 tags .isEmpty () ? null : tags .toArray (new String [0 ]), true );
2019- for (StoragePoolVO pool : zonePoolsLiteral ) {
2016+ for (StoragePoolVO pool : zonePoolsStandard ) {
20202017 if (pool .getHypervisor () == null || pool .getHypervisor ().equals (HypervisorType .Any ) ||
20212018 pool .getHypervisor ().equals (hypervisorType )) {
20222019 matchingPoolIds .add (pool .getId ());
2023- logger .debug ("Found zone-wide pool with literal tags: {} ({})" , pool .getName (), pool .getId ());
2020+ logger .debug ("Found zone-wide pool with standard tags: {} ({})" , pool .getName (), pool .getId ());
20242021 }
20252022 }
20262023
2027- List <StoragePoolVO > zonePoolsRules = _poolJoinDao .findStoragePoolByScopeAndRuleTags (dcId , null , null ,
2024+ List <StoragePoolVO > zonePoolsFlexible = _poolJoinDao .findStoragePoolByScopeAndRuleTags (dcId , null , null ,
20282025 ScopeType .ZONE , tags );
2029- for (StoragePoolVO pool : zonePoolsRules ) {
2026+ for (StoragePoolVO pool : zonePoolsFlexible ) {
20302027 StoragePoolVO poolVO = _poolDao .findById (pool .getId ());
20312028 if (poolVO != null && (poolVO .getHypervisor () == null || poolVO .getHypervisor ().equals (HypervisorType .Any ) ||
20322029 poolVO .getHypervisor ().equals (hypervisorType ))) {
20332030 matchingPoolIds .add (pool .getId ());
2034- logger .debug ("Found zone-wide pool with rule-based tags: {} ({})" , pool .getName (), pool .getId ());
2031+ logger .debug ("Found zone-wide pool with flexible tags: {} ({})" , pool .getName (), pool .getId ());
20352032 }
20362033 }
20372034
20382035 List <ClusterVO > clusters = _clusterDao .listByDcHyType (dcId , hypervisorType .toString ());
20392036 for (ClusterVO cluster : clusters ) {
2040- List <StoragePoolVO > clusterPoolsLiteral = _poolDao .findPoolsByTags (dcId , cluster .getPodId (),
2037+ List <StoragePoolVO > clusterPoolsStandard = _poolDao .findPoolsByTags (dcId , cluster .getPodId (),
20412038 cluster .getId (), tags .isEmpty () ? null : tags .toArray (new String [0 ]), true ,
20422039 VolumeApiServiceImpl .storageTagRuleExecutionTimeout .value ());
2043- for (StoragePoolVO pool : clusterPoolsLiteral ) {
2040+ for (StoragePoolVO pool : clusterPoolsStandard ) {
20442041 matchingPoolIds .add (pool .getId ());
2045- logger .debug ("Found cluster-scoped pool with literal tags: {} ({}) in cluster {}" ,
2042+ logger .debug ("Found cluster-scoped pool with standard tags: {} ({}) in cluster {}" ,
20462043 pool .getName (), pool .getId (), cluster .getName ());
20472044 }
2048- List <StoragePoolVO > clusterPoolsRules = _poolJoinDao .findStoragePoolByScopeAndRuleTags (dcId ,
2045+
2046+ List <StoragePoolVO > clusterPoolsFlexible = _poolJoinDao .findStoragePoolByScopeAndRuleTags (dcId ,
20492047 cluster .getPodId (), cluster .getId (), ScopeType .CLUSTER , tags );
2050- for (StoragePoolVO pool : clusterPoolsRules ) {
2048+ for (StoragePoolVO pool : clusterPoolsFlexible ) {
20512049 matchingPoolIds .add (pool .getId ());
2052- logger .debug ("Found cluster-scoped pool with rule-based tags: {} ({}) in cluster {}" ,
2050+ logger .debug ("Found cluster-scoped pool with flexible tags: {} ({}) in cluster {}" ,
20532051 pool .getName (), pool .getId (), cluster .getName ());
20542052 }
20552053 }
20562054
2057- for (Long poolId : matchingPoolIds ) {
2058- if (allPoolsMap .containsKey (poolId )) {
2059- StoragePool pool = allPoolsMap .get (poolId );
2060- if (StoragePoolStatus .Up .equals (pool .getStatus ())) {
2061- suitablePools .add (pool );
2062- logger .debug ("Added pool {} to suitable pools" , pool .getName ());
2063- } else {
2064- logger .debug ("Skipping pool {} - status is {}, not Up" , pool .getName (), pool .getStatus ());
2065- }
2055+ for (StoragePool pool : allPools ) {
2056+ if (matchingPoolIds .contains (pool .getId ()) && StoragePoolStatus .Up .equals (pool .getStatus ())) {
2057+ suitablePools .add (pool );
2058+ logger .debug ("Added pool {} to suitable pools" , pool .getName ());
20662059 }
20672060 }
20682061
0 commit comments