You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2022/03/30 19:56:33 UTC

[GitHub] [cloudstack] wido opened a new issue #6180: RBD/RADOS volume management should be handled by libvirt

wido opened a new issue #6180:
URL: https://github.com/apache/cloudstack/issues/6180


   ##### ISSUE TYPE
    * Enhancement Request
   
   ##### COMPONENT NAME
   ~~~
   CloudStack Agent
   ~~~
   
   ##### CLOUDSTACK VERSION
   ~~~
   all
   ~~~
   
   ##### SUMMARY
   The CloudStack Agent uses com.ceph.rados.* for many operations as when implementing the RBD storage pool support not all features were supported by Libvirt.
   
   For example: https://github.com/apache/cloudstack/blob/1a304ccf68a75d835cf5e723b56b57155be6ebda/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java#L913
   
   ```
                   IoCTX io = r.ioCtxCreate(pool.getSourceDir());
                   Rbd rbd = new Rbd(io);
                   RbdImage image = rbd.open(uuid);
                   s_logger.debug("Fetching list of snapshots of RBD image " + pool.getSourceDir() + "/" + uuid);
                   List<RbdSnapInfo> snaps = image.snapList();
                   try {
                       for (RbdSnapInfo snap : snaps) {
                           if (image.snapIsProtected(snap.name)) {
                               s_logger.debug("Unprotecting snapshot " + pool.getSourceDir() + "/" + uuid + "@" + snap.name);
                               image.snapUnprotect(snap.name);
                           } else {
                               s_logger.debug("Snapshot " + pool.getSourceDir() + "/" + uuid + "@" + snap.name + " is not protected.");
                           }
                           s_logger.debug("Removing snapshot " + pool.getSourceDir() + "/" + uuid + "@" + snap.name);
                           image.snapRemove(snap.name);
                       }
                       s_logger.info("Successfully unprotected and removed any remaining snapshots (" + snaps.size() + ") of "
                           + pool.getSourceDir() + "/" + uuid + " Continuing to remove the RBD image");
                   } catch (RbdException e) {
                       s_logger.error("Failed to remove snapshot with exception: " + e.toString() +
                           ", RBD error: " + ErrorCode.getErrorMessage(e.getReturnValue()));
                       throw new CloudRuntimeException(e.toString() + " - " + ErrorCode.getErrorMessage(e.getReturnValue()));
                   } finally {
                       s_logger.debug("Closing image and destroying context");
                       rbd.close(image);
                       r.ioCtxDestroy(io);
                   }
               } catch (RadosException e) {
                   s_logger.error("Failed to remove snapshot with exception: " + e.toString() +
                       ", RBD error: " + ErrorCode.getErrorMessage(e.getReturnValue()));
                   throw new CloudRuntimeException(e.toString() + " - " + ErrorCode.getErrorMessage(e.getReturnValue()));
               } catch (RbdException e) {
                   s_logger.error("Failed to remove snapshot with exception: " + e.toString() +
                       ", RBD error: " + ErrorCode.getErrorMessage(e.getReturnValue()));
                   throw new CloudRuntimeException(e.toString() + " - " + ErrorCode.getErrorMessage(e.getReturnValue()));
               }
           }
   ```
   
   Here the CloudStack agent purges any RBD snapshots as they need to be removed prior to removing the RBD image.
   
   Modern libvirt can do this for you (pseudo code):
   
   ```
   StorageVol.delete(VIR_STORAGE_VOL_DELETE_WITH_SNAPSHOTS)
   ```
   
   This removes a lot of lines of code from CloudStack and leverages what libvirt can do for us.
   
   This is just one example, but there are other places where the CloudStack agent uses the librados Java bindings directly while those things can be handled by libvirt.
   
   


-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org