Skip to content

Commit 226e29a

Browse files
committed
Load FIP information during initialize not init
DvrLocalRouter._load_used_fip_information() is called during the class init however in some cases it tries to access a network namespace which hasn't yet been created. This results in NetworkNamespaceNotFound. This change ensures that we instead create any FIP priority rules after the network namespace has been created by calling _load_used_fip_information() from the initialize function rather than in the class instantiation. Closes-Bug: #2025129 Change-Id: I41ffffeca433faab2244ff3d1876ca078ce5ebfb (cherry picked from commit c8c74f1)
1 parent 73ba302 commit 226e29a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

neutron/agent/l3/dvr_local_router.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ def __init__(self, host, *args, **kwargs):
4747
self.rtr_fip_connect = False
4848
self.fip_ns = None
4949
self._pending_arp_set = set()
50+
51+
def initialize(self, process_monitor):
52+
super().initialize(process_monitor)
5053
self._load_used_fip_information()
5154

5255
def _load_used_fip_information(self):

neutron/tests/unit/agent/l3/test_dvr_local_router.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,15 @@ def test__load_used_fip_information(self, mock_add_ip_rule):
287287
self.assertEqual(sorted(ret, key=lambda ret: ret[0]),
288288
fip_rule_prio_list)
289289

290+
@mock.patch.object(router_info.RouterInfo, 'initialize')
291+
def test_initialize_dvr_local_router(self, super_initialize):
292+
ri = self._create_router()
293+
self.mock_load_fip.assert_not_called()
294+
295+
ri.initialize(self.process_monitor)
296+
super_initialize.assert_called_once_with(self.process_monitor)
297+
self.mock_load_fip.assert_called_once()
298+
290299
def test_get_floating_ips_dvr(self):
291300
router = mock.MagicMock()
292301
router.get.return_value = [{'host': HOSTNAME},

0 commit comments

Comments
 (0)