From c4b8956763c2759bd2b9fe511efac5b3edfb226d Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Wed, 18 Aug 2021 09:19:58 -0400 Subject: [PATCH] LVM: Retry lvextend commands on code 139 Retry lvextend commands upon segfault, similar to other LVM calls. This affects the volume extend path. Change-Id: I0c0cb5308246a3dce736eade67b40be063aa78bb Related-Bug: #1901783 Related-Bug: #1932188 Closes-Bug: #1940436 --- cinder/brick/local_dev/lvm.py | 3 +-- cinder/tests/unit/brick/test_brick_lvm.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cinder/brick/local_dev/lvm.py b/cinder/brick/local_dev/lvm.py index ea75b8fecd9..61a3c23faf0 100644 --- a/cinder/brick/local_dev/lvm.py +++ b/cinder/brick/local_dev/lvm.py @@ -832,8 +832,7 @@ class LVM(executor.Executor): try: cmd = LVM.LVM_CMD_PREFIX + ['lvextend', '-L', new_size, '%s/%s' % (self.vg_name, lv_name)] - self._execute(*cmd, root_helper=self._root_helper, - run_as_root=True) + self._run_lvm_command(cmd) except putils.ProcessExecutionError as err: LOG.exception('Error extending Volume') LOG.error('Cmd :%s', err.cmd) diff --git a/cinder/tests/unit/brick/test_brick_lvm.py b/cinder/tests/unit/brick/test_brick_lvm.py index df092b3ad71..b4605446b58 100644 --- a/cinder/tests/unit/brick/test_brick_lvm.py +++ b/cinder/tests/unit/brick/test_brick_lvm.py @@ -456,7 +456,7 @@ class BrickLvmTestCase(test.TestCase): @ddt.data(True, False) def test_lv_extend(self, has_snapshot): - with mock.patch.object(self.vg, '_execute'): + with mock.patch.object(self.vg, '_execute', return_value=('', '')): with mock.patch.object(self.vg, 'lv_has_snapshot'): self.vg.deactivate_lv = mock.MagicMock() self.vg.activate_lv = mock.MagicMock()