From: Adam Gandelman <adam.gandelman@canonical.com>
Date: Wed, 28 Nov 2012 01:51:26 +0000 (-0800)
Subject: Improve provider_location cleanup code for RBD.
X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=940f363dafd8a511e0c37b8a1ce1370e36c5a835;p=openstack-build%2Fcinder-build.git

Improve provider_location cleanup code for RBD.

The RBD driver does not make use of the 'provider_location' field
but the current cleanup code assumes it does.  Ensure the field
is in use before testing whether or not it needs fixing.

Fixes bug 1083818.

Change-Id: Id6ff85101f85e70575ba244c2df7aca0196cf224
(cherry picked from commit d030c5b10e9e8d73d967562259e7db6146347108)
---

diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py
index d64014d5f..b3a4c97b4 100644
--- a/cinder/volume/manager.py
+++ b/cinder/volume/manager.py
@@ -312,7 +312,8 @@ class VolumeManager(manager.SchedulerDependentManager):
 
         # Check for https://bugs.launchpad.net/cinder/+bug/1065702
         volume_ref = self.db.volume_get(context, volume_id)
-        if volume_ref['name'] not in volume_ref['provider_location']:
+        if (volume_ref['provider_location'] and
+            volume_ref['name'] not in volume_ref['provider_location']):
             self.driver.ensure_export(context, volume_ref)
 
     def _copy_image_to_volume(self, context, volume, image_id):