[Openstack] Periodic clean-up of fixed_ip addresses in multi-host DHCP mode

Day, Phil philip.day at hp.com
Fri Apr 27 18:30:18 UTC 2012


Hi Folks,

In multi-host mode the "host" field of a network never seems to get set (as only IPs are allocated, not networks)

However the periodic revovery task in NetworkManager uses the host field to filter what addresses it should consider cleaning up (to catch the case where the message from dnsmasq is either never sent or not delivered for some reason)

    if self.timeout_fixed_ips:
            now = utils.utcnow()
            timeout = FLAGS.fixed_ip_disassociate_timeout
            time = now - datetime.timedelta(seconds=timeout)
            num = self.db.fixed_ip_disassociate_all_by_timeout(context,
                                                               self.host,
                                                               time)
            if num:
                LOG.debug(_('Dissassociated %s stale fixed ip(s)'), num)


Where "db.fixed_ip_disassociate_all_by_timeout"   is:

def fixed_ip_disassociate_all_by_timeout(_context, host, time):
    session = get_session()
    inner_q = session.query(models.Network.id).\
                      filter_by(host=host).\
                      subquery()
    result = session.query(models.FixedIp).\
                     filter(models.FixedIp.network_id.in_(inner_q)).\
                     filter(models.FixedIp.updated_at < time).\
                     filter(models.FixedIp.instance_id != None).\
                     filter_by(allocated=False).\
                     update({'instance_id': None,
                             'leased': False,
                             'updated_at': utils.utcnow()},
                             synchronize_session='fetch')
    return result


So what this seems to do to me is:

-          Find all of the fixed_ips which are:

o   on networks assigned to this host

o   Were last updated more that "Timeout" seconds ago

o   Are associated to an instance

o   Are not allocated

Because in multi-host mode the network host field is always Null, this query does nothing apart from give the DB a good work out every 10 seconds - so there could be a slow leakage of IP addresses.

Has anyone else spotted this - and if so do you have a good strategy for dealing with it ?

It seems that running this on every network_manager every 10 seconds is excessive - so what still running on all netwok_managers but using a long random sleep between runs in mult-host mode ?

Thoughts ?

Cheers,
Phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack/attachments/20120427/b6166eb0/attachment.html>


More information about the Openstack mailing list