From: Alberto Murillo Date: Tue, 30 Jun 2015 21:12:55 +0000 (-0500) Subject: Update expected error message from lvs X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=a0e2f994ff44db495eb4ccb1fad9d132ec994ce9;p=openstack-build%2Fcinder-build.git Update expected error message from lvs drivers/lvm.py uses _volume_not_present() to avoid deleting a snapshot when it does not exist in the lvm backend. This functions uses brick/ local_dev/lvm.py get_lv_info() which expects "not found" as error message. Since LVM2 2.102.112, The error message returned by lvs changed From: One or more specified logical volume(s) not found To: Failed to find logical volume \"%s/%s\" Change-Id: I032a916666918b07d00983a42f10dd8efc17ee8b Closes-Bug: #1470218 --- diff --git a/cinder/brick/local_dev/lvm.py b/cinder/brick/local_dev/lvm.py index 1dfa14fe8..83524856f 100644 --- a/cinder/brick/local_dev/lvm.py +++ b/cinder/brick/local_dev/lvm.py @@ -277,10 +277,10 @@ class LVM(executor.Executor): run_as_root=True) except putils.ProcessExecutionError as err: with excutils.save_and_reraise_exception(reraise=True) as ctx: - if "not found" in err.stderr: + if "not found" in err.stderr or "Failed to find" in err.stderr: ctx.reraise = False - LOG.info(_LI("'Not found' when querying LVM info. " - "(vg_name=%(vg)s, lv_name=%(lv)s"), + LOG.info(_LI("Logical Volume not found when querying " + "LVM info. (vg_name=%(vg)s, lv_name=%(lv)s"), {'vg': vg_name, 'lv': lv_name}) out = None diff --git a/cinder/tests/unit/brick/test_brick_lvm.py b/cinder/tests/unit/brick/test_brick_lvm.py index c7659ea55..a032edfb1 100644 --- a/cinder/tests/unit/brick/test_brick_lvm.py +++ b/cinder/tests/unit/brick/test_brick_lvm.py @@ -98,6 +98,11 @@ class BrickLvmTestCase(test.TestCase): 'fake-vg/lv-nothere' in cmd_string): raise processutils.ProcessExecutionError( stderr="One or more specified logical volume(s) not found.") + elif ('env, LC_ALL=C, lvs, --noheadings, ' + '--unit=g, -o, vg_name,name,size, --nosuffix, ' + 'fake-vg/lv-newerror' in cmd_string): + raise processutils.ProcessExecutionError( + stderr="Failed to find logical volume \"fake-vg/lv-newerror\"") elif ('env, LC_ALL=C, lvs, --noheadings, ' '--unit=g, -o, vg_name,name,size' in cmd_string): if 'fake-unknown' in cmd_string: @@ -180,11 +185,18 @@ class BrickLvmTestCase(test.TestCase): self.assertEqual(self.vg.get_volume('fake-unknown'), None) def test_get_lv_info_notfound(self): + # lv-nothere will raise lvm < 2.102.112 exception self.assertEqual( [], self.vg.get_lv_info( 'sudo', vg_name='fake-vg', lv_name='lv-nothere') ) + # lv-newerror will raise lvm > 2.102.112 exception + self.assertEqual( + [], + self.vg.get_lv_info( + 'sudo', vg_name='fake-vg', lv_name='lv-newerror') + ) def test_get_lv_info_found(self): lv_info = [{'size': '9.50', 'name': 'test-found-lv-name',