Raise specific exception for an invalid protocol connector
Nova's libvirt driver attempts to load up a set of volume
drivers which use os-brick connectors on start of the
nova-compute service. If there is a missing or invalid
mapping, like ISER + s390x, it results in a ValueError and
nova-compute fails to start.
This change raises a specific exception, which is still a
ValueError for backward compatibility, so that Nova can
handle this situation gracefully and not crash.
Change-Id: I1d016c226416cf2b77d6e0393498905f56fd8cde
Partial-Bug: #1639239
(cherry picked from commit f7b8d242f7
)
This commit is contained in:
parent
8c401a68bb
commit
e1b77f9525
|
@ -154,3 +154,8 @@ class InvalidIOHandleObject(BrickException):
|
|||
class VolumeEncryptionNotSupported(Invalid):
|
||||
message = _("Volume encryption is not supported for %(volume_type)s "
|
||||
"volume %(volume_id)s.")
|
||||
|
||||
|
||||
# NOTE(mriedem): This extends ValueError to maintain backward compatibility.
|
||||
class InvalidConnectorProtocol(ValueError):
|
||||
pass
|
||||
|
|
|
@ -29,6 +29,7 @@ from oslo_concurrency import lockutils
|
|||
from oslo_log import log as logging
|
||||
from oslo_utils import importutils
|
||||
|
||||
from os_brick import exception
|
||||
from os_brick.i18n import _
|
||||
from os_brick import initiator
|
||||
from os_brick import utils
|
||||
|
@ -270,7 +271,7 @@ class InitiatorConnector(object):
|
|||
msg = (_("Invalid InitiatorConnector protocol "
|
||||
"specified %(protocol)s") %
|
||||
dict(protocol=protocol))
|
||||
raise ValueError(msg)
|
||||
raise exception.InvalidConnectorProtocol(msg)
|
||||
|
||||
conn_cls = importutils.import_class(connector)
|
||||
return conn_cls(*args, **kwargs)
|
||||
|
|
|
@ -19,6 +19,7 @@ import mock
|
|||
from oslo_concurrency import processutils as putils
|
||||
from oslo_log import log as logging
|
||||
|
||||
from os_brick import exception
|
||||
from os_brick.initiator import connector
|
||||
from os_brick.initiator.connectors import base
|
||||
from os_brick.initiator.connectors import fake
|
||||
|
@ -225,7 +226,7 @@ class ConnectorTestCase(test_base.TestCase):
|
|||
obj = connector.InitiatorConnector.factory("disco", None)
|
||||
self.assertEqual("DISCOConnector", obj.__class__.__name__)
|
||||
|
||||
self.assertRaises(ValueError,
|
||||
self.assertRaises(exception.InvalidConnectorProtocol,
|
||||
connector.InitiatorConnector.factory,
|
||||
"bogus", None)
|
||||
|
||||
|
|
Loading…
Reference in New Issue