Bug 1805644 - [OSP16][Neutron] Adding subnet to router with already assigned IP address failing without error
Summary: [OSP16][Neutron] Adding subnet to router with already assigned IP address fai...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: python-openstacksdk
Version: 16.0 (Train)
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Bernard Cafarelli
QA Contact: Eran Kuris
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-02-21 09:37 UTC by Rafal Szmigiel
Modified: 2020-05-14 12:18 UTC (History)
5 users (show)

Fixed In Version: python-openstacksdk-0.36.1-0.20200225114654.50c9898.el8ost
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-05-14 12:18:28 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
OpenStack Storyboard 2006679 0 None None None 2020-03-03 12:47:19 UTC
OpenStack gerrit 710994 0 None MERGED Handle HTTP errors in add/remove router interface calls 2021-02-08 08:39:53 UTC
OpenStack gerrit 710995 0 None MERGED Fix error handling on add/remove router iface calls 2021-02-08 08:39:53 UTC
Red Hat Product Errata RHBA-2020:2155 0 None None None 2020-05-14 12:18:58 UTC

Description Rafal Szmigiel 2020-02-21 09:37:18 UTC
Description of problem:

While testing DCN/Separate stack scenario we've experienced weird openstack CLI behaviour.

Having a subnet with one router attached already:
(central) [stack@director ~]$ openstack subnet list | grep private
| badc4b9b-6783-4c84-8838-4a471af017b5 | private-left          | 9b6eaf54-50b2-43ba-9801-b29c16254ecf | 172.20.1.0/24   |


(central) [stack@director ~]$ openstack router list
+--------------------------------------+-----------------------+--------+-------+----------------------------------+
| ID                                   | Name                  | Status | State | Project                          |
+--------------------------------------+-----------------------+--------+-------+----------------------------------+
| 4c739f76-cb1f-4102-9f16-4bbd1fab21c7 | router-external-left  | ACTIVE | UP    | 174fde53c1ed4391aea9c2004e4f7a21 |
| 81159da9-a18e-4c46-8527-b352ed477948 | router-external-right | ACTIVE | UP    | 174fde53c1ed4391aea9c2004e4f7a21 |
+--------------------------------------+-----------------------+--------+-------+----------------------------------+

(central) [stack@director ~]$ openstack port list --router router-external-left
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------+--------+
| ID                                   | Name | MAC Address       | Fixed IP Addresses                                                            | Status |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------+--------+
| 2288a5ce-ebf6-4967-aba5-fac917bb3758 |      | fa:16:3e:2e:76:08 | ip_address='172.20.1.1', subnet_id='badc4b9b-6783-4c84-8838-4a471af017b5'     | ACTIVE |
| 82312e95-19ed-43ad-8d98-8011bd6dabb1 |      | fa:16:3e:f6:35:03 | ip_address='192.168.51.180', subnet_id='fe8cc6f9-a34b-499e-bdf6-31e1b9c41c92' | ACTIVE |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------+--------+

I have made an attempt to attach the same subnet (private-left) to the another router (router-external-right):

(central) [stack@director ~]$ openstack port list --router router-external-right
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------+--------+
| ID                                   | Name | MAC Address       | Fixed IP Addresses                                                            | Status |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------+--------+
| bd5932dd-3544-46c2-a003-8f52c9aaaec5 |      | fa:16:3e:47:d8:44 | ip_address='192.168.52.136', subnet_id='3f55f8d9-e26d-4f1a-a055-26cc4c88e818' | ACTIVE |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------+--------+


(central) [stack@director ~]$ openstack router add subnet router-external-right private-left

but the operation wasn't successful (even CLI didn't report any problem):

(central) [stack@director ~]$ openstack port list --router router-external-right
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------+--------+
| ID                                   | Name | MAC Address       | Fixed IP Addresses                                                            | Status |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------+--------+
| bd5932dd-3544-46c2-a003-8f52c9aaaec5 |      | fa:16:3e:47:d8:44 | ip_address='192.168.52.136', subnet_id='3f55f8d9-e26d-4f1a-a055-26cc4c88e818' | ACTIVE |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------+--------+

with debug I can see that API has thrown an error but openstack cli returned exit code 0:

(central) [stack@director ~]$ openstack router add subnet router-external-right private-left --debug
(...)

GET call to network for http://192.168.123.35:9696/v2.0/routers?name=router-external-right used request id req-58392a02-ade7-40c7-92ab-4cd9d295fe64
REQ: curl -g -i -X PUT http://192.168.123.35:9696/v2.0/routers/81159da9-a18e-4c46-8527-b352ed477948/add_router_interface -H "Content-Type: application/json" -H "User-Agent: openstacksdk/0.36.0 keystoneauth1/3.17.1 python-requests/2.20.0 CPython/3.6.8" -H "X-Auth-Token: {SHA256}e97a1622e5f40c87caa1244b889a9a7c38f23dd8d4639c93216be9699e70da32" -d '{"subnet_id": "badc4b9b-6783-4c84-8838-4a471af017b5"}'
http://192.168.123.35:9696 "PUT /v2.0/routers/81159da9-a18e-4c46-8527-b352ed477948/add_router_interface HTTP/1.1" 409 170
RESP: [409] Content-Length: 170 Content-Type: application/json Date: Fri, 21 Feb 2020 09:34:39 GMT X-Openstack-Request-Id: req-085fe5b3-d9a1-43d7-a628-f1100757cd54
RESP BODY: {"NeutronError": {"type": "IpAddressAlreadyAllocated", "message": "IP address 172.20.1.1 already allocated in subnet badc4b9b-6783-4c84-8838-4a471af017b5", "detail": ""}}
PUT call to network for http://192.168.123.35:9696/v2.0/routers/81159da9-a18e-4c46-8527-b352ed477948/add_router_interface used request id req-085fe5b3-d9a1-43d7-a628-f1100757cd54
clean_up AddSubnetToRouter:
END return value: 0

I think there is a problem to properly handle error in this case.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 2 Bernard Cafarelli 2020-02-27 14:59:37 UTC
2 separate issues here.

First, adding a leg to another subnet on a router: "openstack router add subnet" only works for the first router, and adding new ones will fail with IpAddressAlreadyAllocated - we try to allocate the gateway IP for the router port, so there can be only one. If you need to have other routers, you need to create a port in that subnet, and then associate that port to the router. Something like:
$ openstack port create --fixed-ip subnet=private-subnet --network private port_router2
$ openstack router add port router2 port_router2

Second, the client should report the error (which you saw in log), I could not find the relevant fix but remember it. Current master code works fine:
$ openstack router add subnet router2 private-subnet
BadRequestException: 400: Client Error for url: http://10.48.0.137:9696/v2.0/routers/7bae3e02-deec-49a0-8491-72771ce466cb/add_router_interface, Bad router request: Router already has a port on subnet 1825b046-ffd0-43e0-ab87-ccd0611595d6.

I will check on OSP 16 (redeploying in progress), one possible cause is that you used an older client (or one of its components)

Comment 3 Bernard Cafarelli 2020-03-03 12:47:20 UTC
I found the relevant story and master fix, backporting to stable/train (and OSP 16)

Comment 11 errata-xmlrpc 2020-05-14 12:18:28 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:2155


Note You need to log in before you can comment on or make changes to this bug.