Browse Source

Merge "Fix tap device disappear after node restart" into stable/ocata

Zuul 8 months ago
parent
commit
91ea4b6332

+ 3
- 0
manila/network/linux/interface.py View File

@@ -155,6 +155,9 @@ class OVSInterfaceDriver(LinuxInterfaceDriver):
155 155
 
156 156
         else:
157 157
             LOG.warning(_LW("Device %s already exists."), device_name)
158
+            if ns_dev.link.address != mac_address:
159
+                LOG.warning(_LW("Reset mac address to %s"), mac_address)
160
+                ns_dev.link.set_address(mac_address)
158 161
         ns_dev.link.set_up()
159 162
 
160 163
     @device_name_synchronized

+ 4
- 0
manila/share/manager.py View File

@@ -290,6 +290,10 @@ class ShareManager(manager.SchedulerDependentManager):
290 290
         else:
291 291
             self.driver.initialized = True
292 292
 
293
+        if (self.driver.driver_handles_share_servers and
294
+                hasattr(self.driver, 'service_instance_manager')):
295
+            (self.driver.service_instance_manager.network_helper.
296
+             setup_connectivity_with_service_instances())
293 297
         share_instances = self.db.share_instances_get_all_by_host(ctxt,
294 298
                                                                   self.host)
295 299
         LOG.debug("Re-exporting %s shares", len(share_instances))

+ 6
- 0
manila/tests/fake_driver.py View File

@@ -17,6 +17,7 @@ from oslo_log import log
17 17
 import six
18 18
 
19 19
 from manila.share import driver
20
+from manila.tests import fake_service_instance
20 21
 
21 22
 LOG = log.getLogger(__name__)
22 23
 
@@ -39,8 +40,13 @@ class FakeShareDriver(driver.ShareDriver):
39 40
     """
40 41
 
41 42
     def __init__(self, *args, **kwargs):
43
+        self._setup_service_instance_manager()
42 44
         super(FakeShareDriver, self).__init__([True, False], *args, **kwargs)
43 45
 
46
+    def _setup_service_instance_manager(self):
47
+        self.service_instance_manager = (
48
+            fake_service_instance.FakeServiceInstanceManager())
49
+
44 50
     def manage_existing(self, share, driver_options):
45 51
         LOG.debug("Fake share driver: manage")
46 52
         LOG.debug("Fake share driver: driver options: %s",

+ 15
- 0
manila/tests/fake_service_instance.py View File

@@ -29,10 +29,19 @@ class FakeServiceInstanceManager(object):
29 29
         self.share_networks_servers = {}
30 30
         self.fake_server = fake_compute.FakeServer()
31 31
         self.service_instance_name_template = 'manila_fake_service_instance-%s'
32
+        self._network_helper = None
32 33
 
33 34
     def get_service_instance(self, context, share_network_id, create=True):
34 35
         return self.fake_server
35 36
 
37
+    @property
38
+    def network_helper(self):
39
+        return self._get_network_helper()
40
+
41
+    def _get_network_helper(self):
42
+        self._network_helper = FakeNeutronNetworkHelper()
43
+        return self._network_helper
44
+
36 45
     def _create_service_instance(self, context, instance_name,
37 46
                                  share_network_id, old_server_ip):
38 47
         return self.fake_server
@@ -42,3 +51,9 @@ class FakeServiceInstanceManager(object):
42 51
 
43 52
     def _get_service_instance_name(self, share_network_id):
44 53
         return self.service_instance_name_template % share_network_id
54
+
55
+
56
+class FakeNeutronNetworkHelper(object):
57
+
58
+    def setup_connectivity_with_service_instances(self):
59
+        pass

+ 16
- 0
manila/tests/network/linux/test_interface.py View File

@@ -160,6 +160,22 @@ class TestOVSInterfaceDriver(TestBase):
160 160
 
161 161
         self.ip.assert_has_calls(expected)
162 162
 
163
+    def test_plug_reset_mac(self):
164
+        fake_mac_addr = 'aa:bb:cc:dd:ee:ff'
165
+        self.device_exists.return_value = True
166
+
167
+        self.ip().device().link.address = mock.Mock(return_value=fake_mac_addr)
168
+        ovs = interface.OVSInterfaceDriver()
169
+        ovs.plug('tap0',
170
+                 'port-1234',
171
+                 'ff:ee:dd:cc:bb:aa',
172
+                 bridge='br-int')
173
+        expected = [mock.call(),
174
+                    mock.call().device('tap0'),
175
+                    mock.call().device().link.set_address('ff:ee:dd:cc:bb:aa'),
176
+                    mock.call().device().link.set_up()]
177
+        self.ip.assert_has_calls(expected)
178
+
163 179
     def test_unplug(self, bridge=None):
164 180
         if not bridge:
165 181
             bridge = 'br-int'

+ 5
- 0
releasenotes/notes/reset_tap_device_after_node_restart-0690a6beca077b95.yaml View File

@@ -0,0 +1,5 @@
1
+---
2
+fixes:
3
+  - When use driver_handles_share_servers driver,
4
+    reset the tap device after manila-share service
5
+    start.

Loading…
Cancel
Save