floatingip-create:Ignore floating_ip_address when specifying both floating_ip_address and subnet

Bug #1732890 reported by yanpuqing
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Low
Dongcan Ye

Bug Description

When I created floating ip with "floating_ip_address" and "subnet", it ignored "floating_ip_address".
$neutron floatingip-create --floating-ip-address 172.24.4.25 --subnet d5ece368-35fb-4537-be84-eda656250974
Created a new floatingip:
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| created_at | 2017-11-17T09:42:57Z |
| description | |
| fixed_ip_address | |
| floating_ip_address | 172.24.4.10 |
| floating_network_id | fa18e1d7-1f33-48c0-a77f-f192f3c1c6df |
| id | 4d6129a4-9076-4e79-b3f0-b05ce68deb05 |
| port_id | |
| project_id | f0f9361fbf8e495b97eeadae6a81e14d |
| revision_number | 1 |
| router_id | |
| status | DOWN |
| tenant_id | f0f9361fbf8e495b97eeadae6a81e14d |
| updated_at | 2017-11-17T09:42:57Z |
+---------------------+--------------------------------------+

This is my REQ:
DEBUG: keystoneauth.session REQ: curl -g -i -X POST http://10.10.10.7:9696/v2.0/floatingips.json -H "User-Agent: python-neutronclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: {SHA1}0996a50cdaac248681cedb7000dbe71c7bd1a3e0" -d '{"floatingip": {"floating_network_id": "fa18e1d7-1f33-48c0-a77f-f192f3c1c6df", "subnet_id": "d5ece368-35fb-4537-be84-eda656250974", "floating_ip_address": "172.24.4.25"}}'
And this is my RESP:
RESP BODY: {"floatingip": {"router_id": null, "status": "DOWN", "description": "", "tenant_id": "f0f9361fbf8e495b97eeadae6a81e14d", "created_at": "2017-11-17T09:42:57Z", "updated_at": "2017-11-17T09:42:57Z", "floating_network_id": "fa18e1d7-1f33-48c0-a77f-f192f3c1c6df", "fixed_ip_address": null, "floating_ip_address": "172.24.4.10", "revision_number": 1, "project_id": "f0f9361fbf8e495b97eeadae6a81e14d", "port_id": null, "id": "4d6129a4-9076-4e79-b3f0-b05ce68deb05"}}

I think we should make sure the "floating_ip_address" belongs to the "subnet" and create it.
Or we should report a error message when we set these parameters at the same time.

Tags: l3-ipam-dhcp
Revision history for this message
Brian Haley (brian-haley) wrote :

Using the openstackclient you should get a 403 error:

$ openstack floating ip create --floating-ip-address 172.24.4.99 public
Error while executing command: Forbidden (HTTP 403) (Request-ID: req-1167e309-1975-4aa5-b3ae-7930723e0755)

This is an admin-only operation as per the default entry in etc/policy.json:

"create_floatingip:floating_ip_address": "rule:admin_only",

The admin can change that, which is why it isn't documented as admin-only.

Changed in neutron:
status: New → Invalid
Revision history for this message
Dongcan Ye (hellochosen) wrote :

@Brian Haley, the reproduce step is both specify subnet and floating-ip-address:

# neutron floatingip-create --floating-ip-address 172.24.4.101 --subnet 0c280593-3066-4393-bbdc-028b24139314 public

The result is:
Created a new floatingip:
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| created_at | 2017-11-20T02:22:07Z |
| description | |
| fixed_ip_address | |
| floating_ip_address | 172.24.4.3 |
| floating_network_id | 30c2a624-7c53-46a2-a733-b196e7d72b40 |
| id | c94e45c2-05a4-4c00-9cb1-4168db7de6e4 |
| port_id | |
| project_id | a349811205044d119b27a9f09a06bf3e |
| revision_number | 0 |
| router_id | |
| status | DOWN |
| tags | |
| tenant_id | a349811205044d119b27a9f09a06bf3e |
| updated_at | 2017-11-20T02:22:07Z |
+---------------------+--------------------------------------+

While using openstackclient it always using the floating-ip-address, so I think floating-ip-address and subnet is optional.

Changed in neutron:
status: Invalid → Confirmed
affects: neutron → python-neutronclient
yanpuqing (ycx)
Changed in python-neutronclient:
assignee: nobody → yanpuqing (ycx)
Dongcan Ye (hellochosen)
affects: python-neutronclient → neutron
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

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

Changed in neutron:
assignee: yanpuqing (ycx) → Dongcan Ye (hellochosen)
status: Confirmed → In Progress
Revision history for this message
zhaobo (zhaobo6) wrote : Re: floatingip-create:Ignore floating_ip_address when using floating_ip_address and subnet

I test in the master repo.
It's true that neutron-server will ignore the floating_ip_address if the body contains both floating_ip_address and subnet if you are admin priority. For the current behavior, just allow admin to create floating ip by passing floating_ip_address. Why we need to specify a subnet either. Because it will be allocated from a suitable subnet.

So I don't think it is a reasonable usecase.

Changed in neutron:
status: In Progress → Incomplete
Revision history for this message
Akihiro Motoki (amotoki) wrote :

While I agree that it is a rare case where both floating_ip_address and subnet_id are specified when creating a FIP, we need to clarify the behavior of that case. At least the current behavior sounds tricky.

The approach proposed in the above patch sounds reasonable, i.e., if both IP address and subnet are compatible the specified address is used, and if an IP address specified does not match a specified subnet an exception will be returned.

summary: - floatingip-create:Ignore floating_ip_address when using
+ floatingip-create:Ignore floating_ip_address when specifying both
floating_ip_address and subnet
Changed in neutron:
importance: Undecided → Low
tags: added: l3-ipam-dhcp
Changed in neutron:
status: Incomplete → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/521707
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=088e317cd2dd8488feb29a4fa6600227d1810479
Submitter: Zuul
Branch: master

commit 088e317cd2dd8488feb29a4fa6600227d1810479
Author: Dongcan Ye <email address hidden>
Date: Tue Nov 21 11:46:56 2017 +0800

    Honor both floating_ip_address and subnet_id when creating FIP

    In the current code, if user specifies floating-ip-address
    and subnet, we only process the subnet when creating
    the fip port.

    This patch adds floating_ip_address and subnet_id to
    fip port's fixed_ips, if floating_ip_address is not in the subnet,
    InvalidIpForSubnet exception will be raised.

    This patch also fixes a default value error in tests.

    Change-Id: I436353690839281ca7e13eaf792249306b71dd4b
    Closes-Bug: #1732890

Changed in neutron:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 12.0.0.0b3

This issue was fixed in the openstack/neutron 12.0.0.0b3 development milestone.

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.