File 0001-Make-snapshot_delete-more-robust.patch of Package openstack-cinder

From 542b81363da0c1173b0fb5791d5edd555761ea2e Mon Sep 17 00:00:00 2001
From: Dirk Mueller <dirk@dmllr.de>
Date: Thu, 29 Jan 2015 14:11:35 +0100
Subject: [PATCH] Make snapshot_delete more robust

Since there is no equivalent of a force-snapshot-delete,
the normal snapshot-delete should be more robust to
also handle backend errors. In case the backen does not have
the image snapshot anymore, log an info message and succeed the
operation.

Also explicitely handle the ImageBusy that can be raised by remove_snap
to have the standard exception being bubbled up.

Change-Id: I7fe0878dbc07053ac78272b6998513fafa1c36e8
Closes-Bug: #1415905
Related-Bug: #1361926
---
 cinder/volume/drivers/rbd.py | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

Index: cinder-2014.1.4.dev38/cinder/volume/drivers/rbd.py
===================================================================
--- cinder-2014.1.4.dev38.orig/cinder/volume/drivers/rbd.py
+++ cinder-2014.1.4.dev38/cinder/volume/drivers/rbd.py
@@ -676,12 +676,17 @@ class RBDDriver(driver.VolumeDriver):
         volume_name = strutils.safe_encode(snapshot['volume_name'])
         snap_name = strutils.safe_encode(snapshot['name'])
         with RBDVolumeProxy(self, volume_name) as volume:
-            if self._supports_layering():
-                try:
-                    volume.unprotect_snap(snap_name)
-                except self.rbd.ImageBusy:
-                    raise exception.SnapshotIsBusy(snapshot_name=snap_name)
-            volume.remove_snap(snap_name)
+            try:
+                if self._supports_layering():
+                    try:
+                        volume.unprotect_snap(snap_name)
+                    except self.rbd.ImageNotFound:
+                        LOG.info(_("snapshot %s no longer exists in backend")
+                                 % (volume_name))
+                        return
+                volume.remove_snap(snap_name)
+            except self.rbd.ImageBusy:
+                raise exception.SnapshotIsBusy(snapshot_name=snap_name)
 
     def ensure_export(self, context, volume):
         """Synchronously recreates an export for a logical volume."""
openSUSE Build Service is sponsored by