Fix tap device disappear after node restart
When use driver_handles_share_servers driver, the tap device will down and the tap device mac address is changed after restart the node, that will caused manila can not manage share that created by this service. This path fix this issue. When restart manila-share service, call setup_connectivity_with_service_instances() to create host port and check the the mac address. Change-Id: Ibcdd4f58f15a53c69d35db06bc42283859349758 Closes-Bug:#1688155
This commit is contained in:
parent
ed99505bb0
commit
7422aef799
@ -155,6 +155,9 @@ class OVSInterfaceDriver(LinuxInterfaceDriver):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
LOG.warning("Device %s already exists.", device_name)
|
LOG.warning("Device %s already exists.", device_name)
|
||||||
|
if ns_dev.link.address != mac_address:
|
||||||
|
LOG.warning("Reset mac address to %s", mac_address)
|
||||||
|
ns_dev.link.set_address(mac_address)
|
||||||
ns_dev.link.set_up()
|
ns_dev.link.set_up()
|
||||||
|
|
||||||
@device_name_synchronized
|
@device_name_synchronized
|
||||||
|
@ -312,6 +312,10 @@ class ShareManager(manager.SchedulerDependentManager):
|
|||||||
self.driver.initialized = True
|
self.driver.initialized = True
|
||||||
|
|
||||||
_driver_setup()
|
_driver_setup()
|
||||||
|
if (self.driver.driver_handles_share_servers and
|
||||||
|
hasattr(self.driver, 'service_instance_manager')):
|
||||||
|
(self.driver.service_instance_manager.network_helper.
|
||||||
|
setup_connectivity_with_service_instances())
|
||||||
|
|
||||||
self.ensure_driver_resources(ctxt)
|
self.ensure_driver_resources(ctxt)
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ from oslo_log import log
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from manila.share import driver
|
from manila.share import driver
|
||||||
|
from manila.tests import fake_service_instance
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
@ -39,8 +40,13 @@ class FakeShareDriver(driver.ShareDriver):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
self._setup_service_instance_manager()
|
||||||
super(FakeShareDriver, self).__init__([True, False], *args, **kwargs)
|
super(FakeShareDriver, self).__init__([True, False], *args, **kwargs)
|
||||||
|
|
||||||
|
def _setup_service_instance_manager(self):
|
||||||
|
self.service_instance_manager = (
|
||||||
|
fake_service_instance.FakeServiceInstanceManager())
|
||||||
|
|
||||||
def manage_existing(self, share, driver_options):
|
def manage_existing(self, share, driver_options):
|
||||||
LOG.debug("Fake share driver: manage")
|
LOG.debug("Fake share driver: manage")
|
||||||
LOG.debug("Fake share driver: driver options: %s",
|
LOG.debug("Fake share driver: driver options: %s",
|
||||||
|
@ -29,10 +29,19 @@ class FakeServiceInstanceManager(object):
|
|||||||
self.share_networks_servers = {}
|
self.share_networks_servers = {}
|
||||||
self.fake_server = fake_compute.FakeServer()
|
self.fake_server = fake_compute.FakeServer()
|
||||||
self.service_instance_name_template = 'manila_fake_service_instance-%s'
|
self.service_instance_name_template = 'manila_fake_service_instance-%s'
|
||||||
|
self._network_helper = None
|
||||||
|
|
||||||
def get_service_instance(self, context, share_network_id, create=True):
|
def get_service_instance(self, context, share_network_id, create=True):
|
||||||
return self.fake_server
|
return self.fake_server
|
||||||
|
|
||||||
|
@property
|
||||||
|
def network_helper(self):
|
||||||
|
return self._get_network_helper()
|
||||||
|
|
||||||
|
def _get_network_helper(self):
|
||||||
|
self._network_helper = FakeNeutronNetworkHelper()
|
||||||
|
return self._network_helper
|
||||||
|
|
||||||
def _create_service_instance(self, context, instance_name,
|
def _create_service_instance(self, context, instance_name,
|
||||||
share_network_id, old_server_ip):
|
share_network_id, old_server_ip):
|
||||||
return self.fake_server
|
return self.fake_server
|
||||||
@ -42,3 +51,9 @@ class FakeServiceInstanceManager(object):
|
|||||||
|
|
||||||
def _get_service_instance_name(self, share_network_id):
|
def _get_service_instance_name(self, share_network_id):
|
||||||
return self.service_instance_name_template % share_network_id
|
return self.service_instance_name_template % share_network_id
|
||||||
|
|
||||||
|
|
||||||
|
class FakeNeutronNetworkHelper(object):
|
||||||
|
|
||||||
|
def setup_connectivity_with_service_instances(self):
|
||||||
|
pass
|
||||||
|
@ -160,6 +160,22 @@ class TestOVSInterfaceDriver(TestBase):
|
|||||||
|
|
||||||
self.ip.assert_has_calls(expected)
|
self.ip.assert_has_calls(expected)
|
||||||
|
|
||||||
|
def test_plug_reset_mac(self):
|
||||||
|
fake_mac_addr = 'aa:bb:cc:dd:ee:ff'
|
||||||
|
self.device_exists.return_value = True
|
||||||
|
|
||||||
|
self.ip().device().link.address = mock.Mock(return_value=fake_mac_addr)
|
||||||
|
ovs = interface.OVSInterfaceDriver()
|
||||||
|
ovs.plug('tap0',
|
||||||
|
'port-1234',
|
||||||
|
'ff:ee:dd:cc:bb:aa',
|
||||||
|
bridge='br-int')
|
||||||
|
expected = [mock.call(),
|
||||||
|
mock.call().device('tap0'),
|
||||||
|
mock.call().device().link.set_address('ff:ee:dd:cc:bb:aa'),
|
||||||
|
mock.call().device().link.set_up()]
|
||||||
|
self.ip.assert_has_calls(expected)
|
||||||
|
|
||||||
def test_unplug(self, bridge=None):
|
def test_unplug(self, bridge=None):
|
||||||
if not bridge:
|
if not bridge:
|
||||||
bridge = 'br-int'
|
bridge = 'br-int'
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- When use driver_handles_share_servers driver,
|
||||||
|
reset the tap device after manila-share service
|
||||||
|
start.
|
Loading…
Reference in New Issue
Block a user