Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id D5821200B3B for ; Mon, 11 Jul 2016 10:15:09 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D41C5160A78; Mon, 11 Jul 2016 08:15:09 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2A170160A62 for ; Mon, 11 Jul 2016 10:15:09 +0200 (CEST) Received: (qmail 85955 invoked by uid 500); 11 Jul 2016 08:15:08 -0000 Mailing-List: contact dev-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list dev@cloudstack.apache.org Received: (qmail 85944 invoked by uid 99); 11 Jul 2016 08:15:07 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Jul 2016 08:15:07 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CA85FDFFC0; Mon, 11 Jul 2016 08:15:07 +0000 (UTC) From: wido To: dev@cloudstack.apache.org Reply-To: dev@cloudstack.apache.org References: In-Reply-To: Subject: [GitHub] cloudstack pull request #1608: Cleanup RBD contexts after exceptions to prev... Content-Type: text/plain Message-Id: <20160711081507.CA85FDFFC0@git1-us-west.apache.org> Date: Mon, 11 Jul 2016 08:15:07 +0000 (UTC) archived-at: Mon, 11 Jul 2016 08:15:10 -0000 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 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. ---