]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Update expected error message from lvs
authorAlberto Murillo <alberto.murillo.silva@intel.com>
Tue, 30 Jun 2015 21:12:55 +0000 (16:12 -0500)
committerAlberto Murillo <powerbsd@yahoo.com>
Fri, 3 Jul 2015 19:36:23 +0000 (14:36 -0500)
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

cinder/brick/local_dev/lvm.py
cinder/tests/unit/brick/test_brick_lvm.py

index 1dfa14fe847273c0e3b522e029134e9c799fe3d5..83524856ff47c7fcc1d423c8f285e0f5c2cf0ad1 100644 (file)
@@ -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
 
index c7659ea550c0a141e0a8ca9304e316512eb0d434..a032edfb1e57ecf6f0c66eedae7516d245e3942e 100644 (file)
@@ -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',