Skip to content

Commit

Permalink
Only setup dhcp interface if dhcp is not active on network
Browse files Browse the repository at this point in the history
When enabling (DhcpLocalProcess.enable()) dhcp for a network the agent
first sets dhcp interface, then checks if dhcp is curently active and
if it's true then the agent restarts dhcp.
Restart (DhcpBase.restart()) first disables dhcp and then enables it again
by calling DhcpLocalProcess.enable() recursively which in turn sets
dhcp interface again (it doesn't see the port created earlier as network
is not re-fetched from db). This leads to duplicate dhcp interface
for the network.

The fix is to only setup dhcp interface if dhcp is not active.

Closes-Bug: #1339968

Change-Id: I3a6d2fd5b18a97138ac5b699ecd4d4b30dbdbacb
  • Loading branch information
Oleg Bondarev committed Sep 18, 2014
1 parent e31861c commit d144cb8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion neutron/agent/linux/dhcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ def _enable_dhcp(self):

def enable(self):
"""Enables DHCP for this network by spawning a local process."""
interface_name = self.device_manager.setup(self.network)
if self.active:
self.restart()
elif self._enable_dhcp():
interface_name = self.device_manager.setup(self.network)
self.interface_name = interface_name
self.spawn_process()

Expand Down
1 change: 1 addition & 0 deletions neutron/tests/unit/test_linux_dhcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ def test_enable_already_active(self):
lp.enable()

self.assertEqual(lp.called, ['restart'])
self.assertFalse(self.mock_mgr.return_value.setup.called)

def test_enable(self):
attrs_to_mock = dict(
Expand Down

0 comments on commit d144cb8

Please sign in to comment.