DaanHoogland commented on a change in pull request #5249:
URL: https://github.com/apache/cloudstack/pull/5249#discussion_r686121729



##########
File path: 
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
##########
@@ -321,9 +347,13 @@ public StoragePool findStoragePool(DiskProfile dskCh, 
DataCenter dc, Pod pod, Lo
             }
             DataCenterDeployment plan = new DataCenterDeployment(dc.getId(), 
podId, clusterId, hostId, null, null);
 
-            final List<StoragePool> poolList = allocator.allocateToPool(dskCh, 
profile, plan, avoidList, 1);
+            final List<StoragePool> poolList = allocator.allocateToPool(dskCh, 
profile, plan, avoidList, StoragePoolAllocator.RETURN_UPTO_ALL);
             if (poolList != null && !poolList.isEmpty()) {
-                return 
(StoragePool)dataStoreMgr.getDataStore(poolList.get(0).getId(), 
DataStoreRole.Primary);
+                // Check if the preferred storage pool can be used. If yes, 
use it.
+                Optional<StoragePool> storagePool = 
getPreferredStoragePool(poolList, vm);
+
+                return (storagePool.isPresent()) ? (StoragePool) 
this.dataStoreMgr.getDataStore(storagePool.get().getId(), 
DataStoreRole.Primary) :
+                    
(StoragePool)dataStoreMgr.getDataStore(poolList.get(0).getId(), 
DataStoreRole.Primary);

Review comment:
       We can add the availability to the loop condition and break once found, 
can't we? I see your point though. Though the principle stands, I'm not making 
a big issue of it.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to