From ea50df5d242aec7b425c83293d9566018603ed71 Mon Sep 17 00:00:00 2001 From: "andrei.perepiolkin" Date: Thu, 26 Aug 2021 09:23:24 -0400 Subject: [PATCH] JovianDSS: fix iscsi target recovery function ensure_target_volume does not convert volume name to a proper form, causing failure in case of partial target recovery. This patch fixes name convertion. Added import of i18n to handle errors related to _ Change-Id: I567f09b96e4167b387f5bafc434b0b093b6b11fa Closes-Bug: #1941746 --- cinder/tests/unit/volume/drivers/open_e/test_iscsi.py | 11 +++++++---- cinder/volume/drivers/open_e/iscsi.py | 6 +++--- cinder/volume/drivers/open_e/jovian_common/rest.py | 7 ++++--- .../notes/fix-ensure-export-3cccf107a82b35a0.yaml | 5 +++++ 4 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 releasenotes/notes/fix-ensure-export-3cccf107a82b35a0.yaml diff --git a/cinder/tests/unit/volume/drivers/open_e/test_iscsi.py b/cinder/tests/unit/volume/drivers/open_e/test_iscsi.py index d4d2e79399c..a392777aff0 100644 --- a/cinder/tests/unit/volume/drivers/open_e/test_iscsi.py +++ b/cinder/tests/unit/volume/drivers/open_e/test_iscsi.py @@ -1223,7 +1223,7 @@ class TestOpenEJovianDSSDriver(test.TestCase): patches = [ mock.patch.object( jdssd, - "_create_target_volume", + "_ensure_target_volume", return_value=None), mock.patch.object( jdssd, @@ -1233,7 +1233,7 @@ class TestOpenEJovianDSSDriver(test.TestCase): self.start_patches(patches) ret = jdssd.create_export(ctx, vol, "connector") - jdssd._create_target_volume.assert_called_once_with(vol) + jdssd._ensure_target_volume.assert_called_once_with(vol) self.stop_patches(patches) @@ -1397,6 +1397,8 @@ class TestOpenEJovianDSSDriver(test.TestCase): vol = fake_volume.fake_volume_obj(ctx) vol.id = UUID_1 + vname = jcom.vname(UUID_1) + target_name = CONFIG_OK['target_prefix'] + UUID_1 vol.provider_auth = 'chap user_name 123456789012' @@ -1417,7 +1419,8 @@ class TestOpenEJovianDSSDriver(test.TestCase): jdssd._ensure_target_volume(vol) jdssd.ra.is_target.assert_called_once_with(target_name) - jdssd.ra.is_target_lun.assert_called_once_with(target_name, UUID_1) + + jdssd.ra.is_target_lun.assert_called_once_with(target_name, vname) jdssd.ra.get_target_user.assert_called_once_with(target_name) @@ -1452,7 +1455,7 @@ class TestOpenEJovianDSSDriver(test.TestCase): jdssd._ensure_target_volume(vol) jdssd.ra.is_target.assert_called_once_with(target_name) - jdssd.ra.is_target_lun.assert_called_once_with(target_name, UUID_1) + jdssd.ra.is_target_lun.assert_called_once_with(target_name, vname) jdssd._attach_target_volume.assert_called_once_with( target_name, vname) diff --git a/cinder/volume/drivers/open_e/iscsi.py b/cinder/volume/drivers/open_e/iscsi.py index d816153cccd..bbee5978706 100644 --- a/cinder/volume/drivers/open_e/iscsi.py +++ b/cinder/volume/drivers/open_e/iscsi.py @@ -694,7 +694,7 @@ class JovianISCSIDriver(driver.ISCSIDriver): """ LOG.debug("create export for volume: %s.", volume.id) - self._create_target_volume(volume) + self._ensure_target_volume(volume) return {'provider_location': self._get_provider_location(volume.id)} @@ -876,8 +876,8 @@ class JovianISCSIDriver(driver.ISCSIDriver): self._create_target_volume(volume) return - if not self.ra.is_target_lun(target_name, volume.id): - vname = jcom.vname(volume.id) + vname = jcom.vname(volume.id) + if not self.ra.is_target_lun(target_name, vname): self._attach_target_volume(target_name, vname) try: diff --git a/cinder/volume/drivers/open_e/jovian_common/rest.py b/cinder/volume/drivers/open_e/jovian_common/rest.py index 5a08f7b8a4d..24288ca8034 100644 --- a/cinder/volume/drivers/open_e/jovian_common/rest.py +++ b/cinder/volume/drivers/open_e/jovian_common/rest.py @@ -20,6 +20,7 @@ import re from oslo_log import log as logging from cinder import exception +from cinder.i18n import _ from cinder.volume.drivers.open_e.jovian_common import exception as jexc from cinder.volume.drivers.open_e.jovian_common import rest_proxy @@ -45,8 +46,8 @@ class JovianRESTAPI(object): code = resp.get('code', 'Unknown') msg = resp.get('message', 'Unknown') - reason = ("Request to {url} failed with code: {code} " - "of type:{eclass} reason:{message}") + reason = _("Request to {url} failed with code: {code} " + "of type:{eclass} reason:{message}") reason = reason.format(eclass=eclass, code=code, message=msg, @@ -166,7 +167,7 @@ class JovianRESTAPI(object): if resp["error"]: raise jexc.JDSSRESTException( - 'Failed to extend volume {}'.format(resp['error']['message'])) + _('Failed to extend volume %s' % resp['error']['message'])) raise jexc.JDSSRESTException('Failed to extend volume.') diff --git a/releasenotes/notes/fix-ensure-export-3cccf107a82b35a0.yaml b/releasenotes/notes/fix-ensure-export-3cccf107a82b35a0.yaml new file mode 100644 index 00000000000..744114185ca --- /dev/null +++ b/releasenotes/notes/fix-ensure-export-3cccf107a82b35a0.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + JovianDSS driver: `Bug #1941746 `_: Fixed + Fix ensure_export function failure in case of partial target recovery.