Fix s390 "connector not found" issue

This patch introduces a try-catch block on a call to the os-brick
library which may throw a ValueError. os_brick will throw it when
a driver is not supported, so ignoring it and skipping its addition
to the driver list should be the expected behavior. This fix is
required for s390, where nova is currently broken without it.

The issue was resolved in Ocata with changes including [1] and [2],
as well as a change to os_brick [3]. The backport to newton [4] was
abandoned as it requires a raise in the os_brick minimum version.
This fix is a revision of [5], which is essentially a lightweight
version of [1] that only addresses the issue at hand.

[1]: https://review.openstack.org/#/c/395067/
[2]: https://review.openstack.org/#/c/394979/
[3]: https://review.openstack.org/#/c/375415/
[4]: https://review.openstack.org/#/c/428386/
[5]: https://review.openstack.org/#/c/394425/

Change-Id: I638f12ce3deab0338a8d2652398c35acb9280f72
Closes-Bug: 1639239
This commit is contained in:
Arne Recknagel 2017-02-21 16:56:53 +01:00
parent 642caf0c58
commit ec3f159944
2 changed files with 26 additions and 2 deletions

View File

@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from os_brick.initiator import connector
from oslo_config import fixture as fixture_config
from nova import test
@ -29,6 +31,13 @@ class FakeDriver2(FakeDriver):
pass
class FailDriver(object):
def __init__(self):
self.connector = connector.InitiatorConnector.factory(
'UNSUPPORTED', None
)
class ToDriverRegistryTestCase(test.NoDBTestCase):
def assertDriverInstance(self, inst, class_, *args, **kwargs):
@ -59,6 +68,14 @@ class ToDriverRegistryTestCase(test.NoDBTestCase):
FakeDriver2, 'arg1', 'arg2', param1='value1',
param2='value2')
@mock.patch.object(connector.InitiatorConnector, "factory")
def test_driver_dict_from_config_exception(self, mocked_factory):
mocked_factory.side_effect = ValueError
registry = driver.driver_dict_from_config([
'fail=nova.tests.unit.virt.test_driver.FailDriver',
])
self.assertEqual({}, registry)
class DriverMethodTestCase(test.NoDBTestCase):

View File

@ -41,8 +41,15 @@ def driver_dict_from_config(named_driver_config, *args, **kwargs):
for driver_str in named_driver_config:
driver_type, _sep, driver = driver_str.partition('=')
driver_class = importutils.import_class(driver)
try:
driver_registry[driver_type] = driver_class(*args, **kwargs)
except ValueError:
# NOTE(arne_r):
# stable/newton can not enforce os_brick versions that include
# the InvalidConnectorProtocol exception. Since it inherits from
# ValueError, this fix is still compatible with it.
LOG.debug('Unable to load volume driver %s. It is not '
'supported on this host.', driver_type)
return driver_registry