]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
LIO: Fix UnboundLocalError in ensure_export
authorEric Harney <eharney@redhat.com>
Thu, 30 Oct 2014 20:33:40 +0000 (16:33 -0400)
committerEric Harney <eharney@redhat.com>
Thu, 30 Oct 2014 20:50:01 +0000 (16:50 -0400)
If db.volume_get() fails here, volume_info (and chap_auth)
are unbound, and the below usages will fail.

volume_get() failing is the only way to land in the NotFound
handler, so just remove this debug line.  It won't ever have
info to print.

Move code not related to db lookup out of this try block, and
return when NotFound occurs.

Closes-Bug: #1387866

Change-Id: I13a88bec1a66d8a0794b08514cc9844d60f6c809

cinder/volume/iscsi.py

index 82fb12eb77eb8331c2285c0ae2d2ced70a9102df..e18ce821bc288b38cebb400e27b84b88826003c2 100644 (file)
@@ -253,16 +253,17 @@ class LioAdm(_ExportMixin, iscsi.LioAdm):
                       vg_name, conf, old_name=None):
         try:
             volume_info = self.db.volume_get(context, volume['id'])
-            (auth_method,
-             auth_user,
-             auth_pass) = volume_info['provider_auth'].split(' ', 3)
-            chap_auth = self._iscsi_authentication(auth_method,
-                                                   auth_user,
-                                                   auth_pass)
         except exception.NotFound:
-            LOG.debug("volume_info:%s", volume_info)
             LOG.info(_("Skipping ensure_export. No iscsi_target "
                        "provision for volume: %s"), volume['id'])
+            return
+
+        (auth_method,
+         auth_user,
+         auth_pass) = volume_info['provider_auth'].split(' ', 3)
+        chap_auth = self._iscsi_authentication(auth_method,
+                                               auth_user,
+                                               auth_pass)
 
         iscsi_target = 1