]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
TgtAdm: Fix _recreate_backing_lun logging
authorEric Harney <eharney@redhat.com>
Tue, 27 Jan 2015 21:59:53 +0000 (16:59 -0500)
committerEric Harney <eharney@redhat.com>
Tue, 27 Jan 2015 22:06:07 +0000 (17:06 -0500)
If the execute of tgtadm new fails, the exception
thrown skips over the debugging output.

Ensure the output from the command is always
printed.

Change-Id: I9772c0f725cd6a19d4af8acae814a046e6cfdd17

cinder/volume/targets/tgt.py

index a0991045a4cd79973ce4b5c3eb196ea4396b0e1e..52b71bab9f1474b32c6bb1bd979fa629c19f28ca 100644 (file)
@@ -99,19 +99,22 @@ class TgtAdm(iscsi.ISCSITarget):
         # how long should we wait??  I have no idea, let's go big
         # and error on the side of caution
         time.sleep(10)
+
+        (out, err) = (None, None)
         try:
             (out, err) = utils.execute('tgtadm', '--lld', 'iscsi',
                                        '--op', 'new', '--mode',
                                        'logicalunit', '--tid',
                                        tid, '--lun', '1', '-b',
                                        path, run_as_root=True)
-            LOG.debug('StdOut from recreate backing lun: %s' % out)
-            LOG.debug('StdErr from recreate backing lun: %s' % err)
         except putils.ProcessExecutionError as e:
             LOG.error(_LE("Failed to recover attempt to create "
                           "iscsi backing lun for volume "
                           "id:%(vol_id)s: %(e)s")
                       % {'vol_id': name, 'e': e})
+        finally:
+            LOG.debug('StdOut from recreate backing lun: %s' % out)
+            LOG.debug('StdErr from recreate backing lun: %s' % err)
 
     def _iscsi_location(self, ip, target, iqn, lun=None):
         return "%s:%s,%s %s %s" % (ip, self.configuration.iscsi_port,