Comment 4 for bug 898485

Revision history for this message
Jay Lee (hyangii) wrote :

Vish, I understan your comment, But Problem isn't fix yet.
Irrespective of force_dhcp_release, when terminate instance, nova don't touch instance value of fixed_ips table.

 815 def deallocate_fixed_ip(self, context, address, **kwargs):
 816 """Returns a fixed ip to the pool."""
 817 self.db.fixed_ip_update(context, address,
 818 {'allocated': False,
 819 'virtual_interface_id': None})

(only update 'allocated', 'virtual_interface_id')

But, When create instance, instance get a fixed ip from the pool
 787 def allocate_fixed_ip(self, context, instance_id, network, **kwargs):
 788 """Gets a fixed ip from the pool."""
 789 # TODO(vish): when this is called by compute, we can associate compute
 790 # with a network, or a cluster of computes with a network
 791 # and use that network here with a method like
 792 # network_get_by_compute_host
 793 address = None
 794 if network['cidr']:
 795 address = kwargs.get('address', None)
 796 if address:
 797 address = self.db.fixed_ip_associate(context,
 798 address, instance_id,
 799 network['id'])
 800 else:
 801 address = self.db.fixed_ip_associate_pool(context.elevated(),
 802 network['id'],
 803 instance_id)

db.fixed_ip_associate_pool() is
 741 def fixed_ip_associate_pool(context, network_id, instance_id=None, host=None):
 742 session = get_session()
 743 with session.begin():
 744 network_or_none = or_(models.FixedIp.network_id == network_id,
 745 models.FixedIp.network_id == None)
 746 fixed_ip_ref = session.query(models.FixedIp).\
 747 filter(network_or_none).\
 748 filter_by(reserved=False).\
 749 filter_by(deleted=False).\
 750 filter_by(instance=None).\
 751 filter_by(host=None).\
 752 with_lockmode('update').\
 753 first()

method choice fixed_ip what instance==None.
when terminate instance, nova don't update instance value to NULL, So termiated ip address couldn't reuse.