diff options
-rw-r--r-- | nova/network/linux_net.py | 5 | ||||
-rw-r--r-- | nova/network/manager.py | 16 | ||||
-rw-r--r-- | nova/tests/fake_network.py | 3 |
3 files changed, 19 insertions, 5 deletions
diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py index 08a2ae354..a6d785784 100644 --- a/nova/network/linux_net.py +++ b/nova/network/linux_net.py @@ -775,10 +775,13 @@ def get_dhcp_hosts(context, network_ref): host = None if network_ref['multi_host']: host = CONF.host + macs = set() for data in db.network_get_associated_fixed_ips(context, network_ref['id'], host=host): - hosts.append(_host_dhcp(data)) + if data['vif_address'] not in macs: + hosts.append(_host_dhcp(data)) + macs.add(data['vif_address']) return '\n'.join(hosts) diff --git a/nova/network/manager.py b/nova/network/manager.py index 4b3863498..ef967383c 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -778,6 +778,12 @@ class NetworkManager(manager.SchedulerDependentManager): for fixed_ip in fixed_ips: if fixed_ip['address'] == address: self.deallocate_fixed_ip(context, address, host) + # NOTE(vish): this probably isn't a dhcp ip so just + # deallocate it now. In the extremely rare + # case that this is a race condition, we + # will just get a warn in lease or release. + if not fixed_ip.get('leased'): + self.db.fixed_ip_disassociate(context, address) return self.get_instance_nw_info(context, instance_id, rxtx_factor, host) raise exception.FixedIpNotFoundForSpecificInstance( @@ -909,8 +915,9 @@ class NetworkManager(manager.SchedulerDependentManager): fixed_ip = self.db.fixed_ip_get_by_address(context, address) if fixed_ip['instance_uuid'] is None: - msg = _('IP %s leased that is not associated') % address - raise exception.NovaException(msg) + LOG.warn(_('IP %s leased that is not associated'), address, + context=context) + return now = timeutils.utcnow() self.db.fixed_ip_update(context, fixed_ip['address'], @@ -926,8 +933,9 @@ class NetworkManager(manager.SchedulerDependentManager): fixed_ip = self.db.fixed_ip_get_by_address(context, address) if fixed_ip['instance_uuid'] is None: - msg = _('IP %s released that is not associated') % address - raise exception.NovaException(msg) + LOG.warn(_('IP %s released that is not associated'), address, + context=context) + return if not fixed_ip['leased']: LOG.warn(_('IP %s released that was not leased'), address, context=context) diff --git a/nova/tests/fake_network.py b/nova/tests/fake_network.py index 6618c58ea..ac21da628 100644 --- a/nova/tests/fake_network.py +++ b/nova/tests/fake_network.py @@ -148,6 +148,9 @@ class FakeNetworkManager(network_manager.NetworkManager): return [ip for ip in self.fixed_ips if ip['virtual_interface_id'] == vif_id] + def fixed_ip_disassociate(self, context, address): + return True + def __init__(self): self.db = self.FakeDB() self.deallocate_called = None |