Comment 3 for bug 1692567

Revision history for this message
Harald Jensås (harald-jensas) wrote :

I ran this trough pdb, when using segments ip_allocation is DEFERRED instead of IMMEDIATE. Grepping the code I found references in neutron/db/ipam_backend_mixin.py where comments says this happens on routed networks (segments) when host is not known.

No Segment:
-----------
-> self.ipam.allocate_ips_for_port_and_store(
(Pdb) n
> /usr/lib/python2.7/site-packages/neutron/db/db_base_plugin_v2.py(1262)create_port_db()
-> context, port, port_id)
(Pdb) n
> /usr/lib/python2.7/site-packages/neutron/db/db_base_plugin_v2.py(1263)create_port_db()
-> db_port['ip_allocation'] = ipa.IP_ALLOCATION_IMMEDIATE

...

-> return db_port
(Pdb) print fixed_ips
[{u'subnet_id': u'64e6df15-4b8f-478b-94fa-b4e99abcea7f', u'ip_address': u'192.168.24.250'}]
(Pdb) print db_port
<neutron.db.models_v2.Port[object at 76b2cd0] {project_id=u'e6d293744b534510ae2af1c9be08666c', id='e11a7193-bb17-471f-a393-d57c0c338b6a', name=u'fixed-ip-test', network_id=u'509106ce-7e19-4985-aa57-2e71a830d520', mac_address='fa:16:3e:dd:51:f5', admin_state_up=True, status='DOWN', device_id='', device_owner='', ip_allocation='immediate', standard_attr_id=12}>

With Segment:
-------------
-> self.ipam.allocate_ips_for_port_and_store(
(Pdb) n
> /usr/lib/python2.7/site-packages/neutron/db/db_base_plugin_v2.py(1262)create_port_db()
-> context, port, port_id)
(Pdb) n
DeferIpam: DeferIpa...ferred',)
> /usr/lib/python2.7/site-packages/neutron/db/db_base_plugin_v2.py(1262)create_port_db()
-> context, port, port_id)
(Pdb) n
> /usr/lib/python2.7/site-packages/neutron/db/db_base_plugin_v2.py(1264)create_port_db()
-> except ipam_exc.DeferIpam:
(Pdb) n
> /usr/lib/python2.7/site-packages/neutron/db/db_base_plugin_v2.py(1265)create_port_db()
-> db_port['ip_allocation'] = ipa.IP_ALLOCATION_DEFERRED

...

-> return db_port
(Pdb) print fixed_ips
[{u'subnet_id': u'86668c2f-d226-4459-babc-8be614a1ee61', u'ip_address': u'172.20.0.250'}]
(Pdb) print db_port
<neutron.db.models_v2.Port[object at 635de90] {project_id=u'6a3e466b1a7245cf832e717edc053938', id='6ff51cca-0877-4a4b-aad3-a097d4ac2ce4', name=u'fixed-ip-test', network_id=u'f19d0817-7394-4f5d-840f-e440476f05b2', mac_address='fa:16:3e:00:cd:13', admin_state_up=True, status='DOWN', device_id='', device_owner='', ip_allocation='deferred', standard_attr_id=29}>

https://github.com/openstack/neutron/blob/master/neutron/db/db_base_plugin_v2.py#L1259:L1264
    try:
        self.ipam.allocate_ips_for_port_and_store(
            context, port, port_id)
        db_port['ip_allocation'] = ipa.IP_ALLOCATION_IMMEDIATE
    except ipam_exc.DeferIpam:
        db_port['ip_allocation'] = ipa.IP_ALLOCATION_DEFERRED

https://github.com/openstack/neutron/blob/master/neutron/db/ipam_backend_mixin.py#L695:L696
    # No, must be a deferred IP port because there are matching
    # subnets. Happens on routed networks when host isn't known.

https://github.com/openstack/neutron/blob/master/neutron/db/ipam_backend_mixin.py#L740:L742
    Updates the port's IPs based on any new fixed_ips passed in or if
    deferred IP allocation is in effect because allocation requires host
    binding information that wasn't provided until port update.