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:
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)
I found the relevant story and master fix, backporting to stable/train (and OSP 16)
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