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


##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ClvmStorageAdaptor.java:
##########
@@ -89,6 +90,54 @@ public KVMStoragePool createStoragePool(String name, String 
host, int port, Stri
         }
     }
 
+    @Override
+    public boolean deleteStoragePool(String uuid) {
+        logger.info("Attempting to remove CLVM/CLVM_NG storage pool {} from 
libvirt", uuid);
+
+        if (decStoragePoolRefCount(uuid)) {
+            logger.info("deleteStoragePool: CLVM/CLVM_NG storage pool {} still 
in use", uuid);
+            return true;
+        }
+
+        try {
+            return undefineInactiveClvmPool(LibvirtConnection.getConnection(), 
uuid);
+        } catch (LibvirtException e) {
+            throw new CloudRuntimeException(e.toString(), e);
+        }
+    }
+
+    private boolean undefineInactiveClvmPool(Connect conn, String uuid) throws 
LibvirtException {
+        StoragePool sp = lookupClvmPool(conn, uuid);
+        if (sp == null) {
+            logger.warn("CLVM/CLVM_NG storage pool {} doesn't exist in 
libvirt. Assuming it is already removed", uuid);
+            return true;
+        }
+
+        try {
+            if (sp.isActive() == 1) {
+                sp.destroy();
+            }

Review Comment:
    CloudStack only deletes a primary storage pool after all volumes in it have 
been removed, so there are no CloudStack-managed LVs left in use when destroy() 
runs. destroy() is only used for a legacy/autostarted pool that is active; it 
stops the libvirt pool, which deactivates the VG's LVs on that host. The VG, 
its metadata, the lockspace and the LUN are not removed. Removing those remains 
the operator's responsibility.



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