Wrong 'fixed_ips' defaults in OS::Neutron::Port

Bug #1271597 reported by Alexander Ignatov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Medium
Sergey Kraynev

Bug Description

Let's assume we have an template:
{
    "Resources" : {
        "port" : {
            "Type" : "OS::Neutron::Port",
            "Properties" : {
               "network_id" : "daeb24b2-5edd-43f4-abdf-11355c78a27f"
            }
        }
    }
}

In this case after stack-create Neutron will create port without assigned fixed_ips. This this because heat engine explicitly assigns default value for 'fixed_ips'=[]. See here:
https://github.com/openstack/heat/blob/master/heat/engine/resources/neutron/port.py#L75

It is wrong behaviour because in case of missing 'fixed_ips' neutron should assign some fixed ip address to the port. Look how it is implemented in neutronclient:
==================example.py==============
from neutronclient.v2_0 import client as neutron_client

neutron = neutron_client.Client(
    username="admin",
    password="nova",
    tenant_name="admin",
    auth_url="http://172.18.79.141:5000/v2.0/")

# Case 1. Creating port with missed fixed_ips param
neutron.create_port({'port': {'network_id': '4735f69e-c9e7-444c-a8bb-b8ec361a4f72',
                                     'name': 'port_with_ip',
                                     'security_groups': [],
                                     'admin_state_up': True} })

# Case 2. Creating port with fixed_ips=[]
neutron.create_port({'port': {'network_id': '4735f69e-c9e7-444c-a8bb-b8ec361a4f72',
                                     'name': 'port_without_ip',
                                     'security_groups': [],
                                     'fixed_ips': [],
                                     'admin_state_up': True} })
========================================

In the above example created ports will look like are as follows:
stack@stack:~$ neutron port-list
| some-uuid1 | port_with_ip | fa:16:3e:53:f3:4b | {"subnet_id": "495328abcf60", "ip_address": "10.0.0.14"} |
| some-uuid2 | port_without_ip | fa:16:3e:55:6f:2d | |

============================================

If you can see in case 1 when 'fixed_ips' param is missed in port definintion neutron automatically assigns some address and subnet.

So Heat should allow both cases with missed fixed_ips and user-defined.

Revision history for this message
Thomas Herve (therve) wrote :

Okay, that's unfortunate, but who thought that doing that in Neutron was a good idea? I mean seriously this is a really strange behavior, and completely implicit. I'm okay to fix that in Heat, but I think a bug should be reported in Neutron to fix this.

Changed in heat:
milestone: none → icehouse-3
importance: Undecided → Medium
Revision history for this message
Eugene Nikanorov (enikanorov) wrote :

Thomas, why do you think it is a strange behavior? You get exactly what you ask for: a port with fixed_ips = []

Changed in heat:
assignee: nobody → Sergey Kraynev (skraynev)
Revision history for this message
Thomas Herve (therve) wrote :

Eugene: I'm not saying that the behavior with fixed_ips = [] is strange, but that omitting fixed_ips and passing an empty list giving you different behavior is counter-intuitive.

Nowhere in the documentation I can find mention of that.

On top of that, we already had to fix bugs like bug #1224472 so that means for the same attribute None is not valid, empty list and omitting the attribute gives you different behavior. That is super confusing, at least to me.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (master)

Fix proposed to branch: master
Review: https://review.openstack.org/68648

Changed in heat:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

Reviewed: https://review.openstack.org/68648
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=0cfdd6e280616de4c9fd5b6a1819e39b6e7fd775
Submitter: Jenkins
Branch: master

commit 0cfdd6e280616de4c9fd5b6a1819e39b6e7fd775
Author: Sergey Kraynev <email address hidden>
Date: Thu Jan 23 09:37:28 2014 -0500

    Delete fixed_ips if it's empty list

    If neutronclient gets fixed_ips = [], created port will not get assigned
    ip address. In current patch fixed_ips will be deleted from properties,
    if it is empty list. So created port always gets assigned ip address.

    Change-Id: I8344180b07ffb61019264f44d23aa400aa1ace31
    Closes-bug: #1271597

Changed in heat:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in heat:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in heat:
milestone: icehouse-3 → 2014.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.