From: Eric Harney Date: Thu, 30 Oct 2014 20:33:40 +0000 (-0400) Subject: LIO: Fix UnboundLocalError in ensure_export X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=dac4e044660b20eb4aed80cfe58cd9d5b88e14a7;p=openstack-build%2Fcinder-build.git LIO: Fix UnboundLocalError in ensure_export 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 --- diff --git a/cinder/volume/iscsi.py b/cinder/volume/iscsi.py index 82fb12eb7..e18ce821b 100644 --- a/cinder/volume/iscsi.py +++ b/cinder/volume/iscsi.py @@ -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