Skip to content

Commit b37a2f8

Browse files
brianphaleyralonsoh
authored andcommitted
Start metadata proxy even if IPv6 DAD fails
A recent change suppressed the IPv6 DAD failure and removed the address when multiple DHCP agents were configured on the same network, https://review.opendev.org/c/openstack/neutron/+/880957 But it also changed the behavior to not enable IPv4 metadata in this case. Restore the old behavior by not returning early in the DAD failure case. The callback that builds the config file was moved until after the address was bound to make the two steps more obvious. Conflicts: neutron/tests/unit/agent/metadata/test_driver.py Related-bug: #1953165 Change-Id: I8436c6c9da9a2533ca27ff7312f5b2c7ea41e94f (cherry picked from commit 846003c) (cherry picked from commit e7f85ab) (cherry picked from commit 1a711f3)
1 parent 0a590e5 commit b37a2f8

File tree

2 files changed

+30
-26
lines changed

2 files changed

+30
-26
lines changed

neutron/agent/metadata/driver.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,6 @@ def spawn_monitored_metadata_proxy(cls, monitor, ns_name, port, conf,
255255
bind_address="0.0.0.0", network_id=None,
256256
router_id=None, bind_address_v6=None,
257257
bind_interface=None):
258-
uuid = network_id or router_id
259-
callback = cls._get_metadata_proxy_callback(
260-
bind_address, port, conf,
261-
network_id=network_id, router_id=router_id,
262-
bind_address_v6=bind_address_v6, bind_interface=bind_interface)
263-
pm = cls._get_metadata_proxy_process_manager(uuid, conf,
264-
ns_name=ns_name,
265-
callback=callback)
266258
if bind_interface is not None and bind_address_v6 is not None:
267259
# HAProxy cannot bind() until IPv6 Duplicate Address Detection
268260
# completes. We must wait until the address leaves its 'tentative'
@@ -290,7 +282,18 @@ def spawn_monitored_metadata_proxy(cls, monitor, ns_name, port, conf,
290282
except Exception as exc:
291283
# do not re-raise a delete failure, just log
292284
LOG.info('Address deletion failure: %s', str(exc))
293-
return
285+
286+
# Do not use the address or interface when DAD fails
287+
bind_address_v6 = bind_interface = None
288+
289+
uuid = network_id or router_id
290+
callback = cls._get_metadata_proxy_callback(
291+
bind_address, port, conf,
292+
network_id=network_id, router_id=router_id,
293+
bind_address_v6=bind_address_v6, bind_interface=bind_interface)
294+
pm = cls._get_metadata_proxy_process_manager(uuid, conf,
295+
ns_name=ns_name,
296+
callback=callback)
294297
pm.enable()
295298
monitor.register(uuid, METADATA_SERVICE_NAME, pm)
296299
cls.monitors[router_id] = pm

neutron/tests/unit/agent/metadata/test_driver.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,12 @@ def _test_spawn_metadata_proxy(self, dad_failed=False):
176176
"%s.conf" % router_id)
177177
mock_open = self.useFixture(
178178
lib_fixtures.OpenFixture(cfg_file)).mock_open
179+
bind_v6_line = 'bind %s:%s interface %s' % (
180+
self.METADATA_DEFAULT_IPV6, self.METADATA_PORT, 'fake-if')
179181
if dad_failed:
180182
mock_wait.side_effect = ip_lib.DADFailed(
181-
address=self.METADATA_DEFAULT_IP, reason='DAD failed')
183+
address=self.METADATA_DEFAULT_IPV6, reason='DAD failed')
184+
bind_v6_line = ''
182185
else:
183186
mock_wait.return_value = True
184187
agent.metadata_driver.spawn_monitored_metadata_proxy(
@@ -197,8 +200,6 @@ def _test_spawn_metadata_proxy(self, dad_failed=False):
197200

198201
log_tag = ("haproxy-" + metadata_driver.METADATA_SERVICE_NAME +
199202
"-" + router_id)
200-
bind_v6_line = 'bind %s:%s interface %s' % (
201-
self.METADATA_DEFAULT_IPV6, self.METADATA_PORT, 'fake-if')
202203
cfg_contents = metadata_driver._HAPROXY_CONFIG_TEMPLATE % {
203204
'user': self.EUNAME,
204205
'group': self.EGNAME,
@@ -214,26 +215,26 @@ def _test_spawn_metadata_proxy(self, dad_failed=False):
214215
'bind_v6_line': bind_v6_line}
215216

216217
if dad_failed:
217-
agent.process_monitor.register.assert_not_called()
218218
mock_del.assert_called_once_with(self.METADATA_DEFAULT_IPV6,
219219
'fake-if',
220220
namespace=router_ns)
221221
else:
222-
mock_open.assert_has_calls([
223-
mock.call(cfg_file, 'w'),
224-
mock.call().write(cfg_contents)], any_order=True)
225-
226-
ip_mock.assert_has_calls([
227-
mock.call(namespace=router_ns),
228-
mock.call().netns.execute(netns_execute_args,
229-
addl_env=None, run_as_root=True)
230-
])
231-
232-
agent.process_monitor.register.assert_called_once_with(
233-
router_id, metadata_driver.METADATA_SERVICE_NAME,
234-
mock.ANY)
235222
mock_del.assert_not_called()
236223

224+
mock_open.assert_has_calls([
225+
mock.call(cfg_file, 'w'),
226+
mock.call().write(cfg_contents)], any_order=True)
227+
228+
ip_mock.assert_has_calls([
229+
mock.call(namespace=router_ns),
230+
mock.call().netns.execute(netns_execute_args, addl_env=None,
231+
run_as_root=True)
232+
])
233+
234+
agent.process_monitor.register.assert_called_once_with(
235+
router_id, metadata_driver.METADATA_SERVICE_NAME,
236+
mock.ANY)
237+
237238
def test_spawn_metadata_proxy(self):
238239
self._test_spawn_metadata_proxy()
239240

0 commit comments

Comments
 (0)