Pearl1594 commented on code in PR #12617:
URL: https://github.com/apache/cloudstack/pull/12617#discussion_r3376567340


##########
engine/storage/src/main/java/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java:
##########
@@ -493,6 +645,31 @@ public EndPoint select(DataObject object, StorageAction 
action, boolean encrypti
             }
             case DELETEVOLUME: {
                 VolumeInfo volume = (VolumeInfo) object;
+
+                // For CLVM volumes, route to the host holding the exclusive 
lock
+                if (volume.getHypervisorType() == 
Hypervisor.HypervisorType.KVM) {
+                    DataStore store = volume.getDataStore();
+                    if (store.getRole() == DataStoreRole.Primary) {
+                        StoragePoolVO pool = 
_storagePoolDao.findById(store.getId());
+                        if (pool != null && 
ClvmPoolManager.isClvmPoolType(pool.getPoolType())) {
+                            Long lockHostId = getClvmLockHostId(volume);
+                            if (lockHostId != null) {
+                                logger.info("Routing CLVM volume {} deletion 
to lock holder host {}",
+                                        volume.getUuid(), lockHostId);
+                                EndPoint ep = 
getEndPointFromHostId(lockHostId);
+                                if (ep != null) {
+                                    return ep;
+                                }
+                                logger.warn("Could not get endpoint for CLVM 
lock host {}, falling back to default selection",
+                                        lockHostId);
+                            } else {
+                                logger.debug("No CLVM lock host tracked for 
volume {}, using default endpoint selection",
+                                        volume.getUuid());
+                            }
+                        }
+                    }
+                }

Review Comment:
   done



-- 
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