cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wido <...@git.apache.org>
Subject [GitHub] cloudstack pull request #1608: Cleanup RBD contexts after exceptions to prev...
Date Mon, 11 Jul 2016 08:15:07 GMT
Github user wido commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1608#discussion_r70217007
  
    --- Diff: plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
---
    @@ -863,26 +864,30 @@ public boolean deletePhysicalDisk(String uuid, KVMStoragePool pool,
Storage.Imag
                     RbdImage image = rbd.open(uuid);
                     s_logger.debug("Fetching list of snapshots of RBD image " + pool.getSourceDir()
+ "/" + uuid);
                     List<RbdSnapInfo> snaps = image.snapList();
    -                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.");
    +                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.debug("Removing snapshot " + pool.getSourceDir() + "/" +
uuid + "@" + snap.name);
    -                    image.snapRemove(snap.name);
    +                    s_logger.info("Succesfully unprotected and removed any remaining
snapshots (" + snaps.size() + ") of "
    +                        + pool.getSourceDir() + "/" + uuid + " Continuing to remove the
RBD image");
    +                } catch (RbdException e) {
    +                    throw new CloudRuntimeException(e.toString() + " - " + ErrorCode.getErrorMessage(e.getReturnValue()));
    +                } finally {
    +                    s_logger.debug("Closing image and destroying context");
    +                    rbd.close(image);
    +                    r.ioCtxDestroy(io);
    --- End diff --
    
    Good catch with the finally!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message