This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git

commit cc1dcf51b7728185f89bfe966dfc713184e3bb86
Merge: cb0527d7050 bf116762788
Author: Rohit Yadav <rohit.ya...@shapeblue.com>
AuthorDate: Thu Aug 8 11:37:21 2024 +0530

    Merge remote-tracking branch 'origin/4.19'
    
    Signed-off-by: Rohit Yadav <rohit.ya...@shapeblue.com>

 .../kvm/storage/LibvirtStorageAdaptor.java         | 53 ++++++++++++++++------
 ...est_acl_sharednetwork_deployVM-impersonation.py | 16 +++----
 tools/marvin/marvin/cloudstackException.py         |  1 +
 3 files changed, 47 insertions(+), 23 deletions(-)

diff --cc 
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
index 6b9e52c3e26,df6c047e7e2..c0f6e44cddd
--- 
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
+++ 
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
@@@ -773,26 -766,53 +773,54 @@@ public class LibvirtStorageAdaptor impl
          }
      }
  
+     private boolean destroyStoragePool(Connect conn, String uuid) throws 
LibvirtException {
+         StoragePool sp;
+         try {
+             sp = conn.storagePoolLookupByUUIDString(uuid);
+         } catch (LibvirtException exc) {
 -            s_logger.warn("Storage pool " + uuid + " doesn't exist in 
libvirt. Assuming it is already removed");
 -            s_logger.warn(exc.getStackTrace());
++            logger.warn("Storage pool " + uuid + " doesn't exist in libvirt. 
Assuming it is already removed");
++            logger.warn(exc.getStackTrace());
+             return true;
+         }
+ 
+         if (sp != null) {
+             if (sp.isPersistent() == 1) {
+                 sp.destroy();
+                 sp.undefine();
+             } else {
+                 sp.destroy();
+             }
+             sp.free();
+ 
+             return true;
+         } else {
 -            s_logger.warn("Storage pool " + uuid + " doesn't exist in 
libvirt. Assuming it is already removed");
++            logger.warn("Storage pool " + uuid + " doesn't exist in libvirt. 
Assuming it is already removed");
+             return false;
+         }
+     }
+ 
+     private boolean destroyStoragePoolHandleException(Connect conn, String 
uuid)
+     {
+         try {
+             return destroyStoragePool(conn, uuid);
+         } catch (LibvirtException e) {
 -            s_logger.error(String.format("Failed to destroy libvirt pool %s: 
%s", uuid, e));
++            logger.error(String.format("Failed to destroy libvirt pool %s: 
%s", uuid, e));
+         }
+         return false;
+     }
+ 
      @Override
      public boolean deleteStoragePool(String uuid) {
 -        s_logger.info("Attempting to remove storage pool " + uuid + " from 
libvirt");
 -        Connect conn;
 +        logger.info("Attempting to remove storage pool " + uuid + " from 
libvirt");
 +        Connect conn = null;
          try {
              conn = LibvirtConnection.getConnection();
          } catch (LibvirtException e) {
              throw new CloudRuntimeException(e.toString());
          }
  
-         StoragePool sp = null;
          Secret s = null;
 +
-         try {
-             sp = conn.storagePoolLookupByUUIDString(uuid);
-         } catch (LibvirtException e) {
-             logger.warn("Storage pool " + uuid + " doesn't exist in libvirt. 
Assuming it is already removed");
-             return true;
-         }
- 
          /*
           * Some storage pools, like RBD also have 'secret' information stored 
in libvirt
           * Destroy them if they exist
@@@ -827,10 -841,11 +849,11 @@@
                          " again in a few seconds");
                  String result = Script.runSimpleBashScript("sleep 5 && umount 
" + targetPath);
                  if (result == null) {
 -                    s_logger.info("Succeeded in unmounting " + targetPath);
 +                    logger.info("Succeeded in unmounting " + targetPath);
+                     destroyStoragePoolHandleException(conn, uuid);
                      return true;
                  }
 -                s_logger.error("Failed to unmount " + targetPath);
 +                logger.error("Failed to unmount " + targetPath);
              }
              throw new CloudRuntimeException(e.toString(), e);
          }

Reply via email to