(转载)[BUG] Neutron创建虚拟路由器,端口状态为down,设置路由网关未生效

官方原文链接:https://review.openstack.org/#/c/258493

 /usr/lib/python2.7/site-packages/neutron/agent/linux/ip_lib.py

上部为修改后,下部为未修改源文件。

 

OpenStack版本:Liberty

系统平台:CentOS 7.2 64bit

网络模型:VLAN(external)+VXLAN(private)

###############################################################

1.现象

创建虚拟路由器,将子网关联上去,并设置到external的路由网关

 

[plain] view plain copy
 
  1. neutron router-create router  
  2. neutron router-interface-add router private  
  3. neutron router-gateway-set router provider-91  
查看路由端口

 

 

[plain] view plain copy
 
  1. neutron router-port-list router  
  2. +--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+  
  3. | id                                   | name | mac_address       | fixed_ips                                                                             |  
  4. +--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+  
  5. | 0b7755a1-70a2-4b3c-84a1-cdbe945b0f0b |      | fa:16:3e:3e:86:1b | {"subnet_id": "aba7f133-8a02-41a1-9fec-4b26dac82503", "ip_address": "192.168.91.106"} |  
  6. | e55502e7-4779-4c03-9468-dbe401bcb876 |      | fa:16:3e:3f:6f:49 | {"subnet_id": "1a04665d-92a2-416d-aaea-c68455ee3fe3", "ip_address": "172.16.1.1"}     |  
  7. +--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+  
在external测试路由网关IP发现不通,查看路由网关端口发现状态为DOWN,如下:
[plain] view plain copy
 
  1. neutron port-list  
  2. +--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+  
  3. | id                                   | name | mac_address       | fixed_ips                                                                             |  
  4. +--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+  
  5. | 0b7755a1-70a2-4b3c-84a1-cdbe945b0f0b |      | fa:16:3e:3e:86:1b | {"subnet_id": "aba7f133-8a02-41a1-9fec-4b26dac82503", "ip_address": "192.168.91.106"} |  
  6. | 11265aeb-2e5b-490a-9c02-5e29c59fb73d |      | fa:16:3e:63:61:c1 | {"subnet_id": "aba7f133-8a02-41a1-9fec-4b26dac82503", "ip_address": "192.168.91.100"} |  
  7. | 1a2261d2-b5c0-4503-b0ce-8dab7690d96a |      | fa:16:3e:90:fa:0b | {"subnet_id": "aba7f133-8a02-41a1-9fec-4b26dac82503", "ip_address": "192.168.91.105"} |  
  8. | 2f41bf61-9679-4677-99bc-45cc18ff05cc |      | fa:16:3e:f8:dc:09 | {"subnet_id": "c4347434-781c-4c1c-b8b8-a963b5e80b77", "ip_address": "192.168.91.80"}  |  
  9. | 30095087-8c71-4fba-88ce-af0887b8e091 |      | fa:16:3e:31:d3:6a | {"subnet_id": "aba7f133-8a02-41a1-9fec-4b26dac82503", "ip_address": "192.168.91.101"} |  
  10. | 4b011b62-77cb-4642-9bcf-b80a9296c703 |      | fa:16:3e:ce:ee:a9 | {"subnet_id": "1a04665d-92a2-416d-aaea-c68455ee3fe3", "ip_address": "172.16.1.2"}     |  
  11. | 6470514b-c1e9-4d6e-88b3-22dde2f00fca |      | fa:16:3e:a2:d5:55 | {"subnet_id": "aba7f133-8a02-41a1-9fec-4b26dac82503", "ip_address": "192.168.91.104"} |  
  12. | 8e1802f6-1d68-4511-8232-781f0451ea15 |      | fa:16:3e:84:b7:b8 | {"subnet_id": "c4347434-781c-4c1c-b8b8-a963b5e80b77", "ip_address": "192.168.91.81"}  |  
  13. | a6c31bc9-7ee0-46da-943a-9836270a9801 |      | fa:16:3e:9e:0a:00 | {"subnet_id": "1a04665d-92a2-416d-aaea-c68455ee3fe3", "ip_address": "172.16.1.3"}     |  
  14. | e55502e7-4779-4c03-9468-dbe401bcb876 |      | fa:16:3e:3f:6f:49 | {"subnet_id": "1a04665d-92a2-416d-aaea-c68455ee3fe3", "ip_address": "172.16.1.1"}     |  
  15. +--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+   
  1. neutron port-show 0b7755a1-70a2-4b3c-84a1-cdbe945b0f0b  
  2. +-----------------------+--------------------------------------------------------------------------------------------------------------------+  
  3. | Field                 | Value                                                                                                              |  
  4. +-----------------------+--------------------------------------------------------------------------------------------------------------------+  
  5. | admin_state_up        | True                                                                                                               |  
  6. | allowed_address_pairs |                                                                                                                    |  
  7. | binding:host_id       | controller                                                                                                         |  
  8. | binding:profile       | {}                                                                                                                 |  
  9. | binding:vif_details   | {"port_filter": true, "ovs_hybrid_plug": true}                                                                     |  
  10. | binding:vif_type      | ovs                                                                                                                |  
  11. | binding:vnic_type     | normal                                                                                                             |  
  12. | device_id             | a9fd9767-2c15-4eb6-8c76-49dcce18fc7f                                                                               |  
  13. | device_owner          | network:router_gateway                                                                                             |  
  14. | dns_assignment        | {"hostname": "host-192-168-91-106", "ip_address": "192.168.91.106", "fqdn": "host-192-168-91-106.openstacklocal."} |  
  15. | dns_name              |                                                                                                                    |  
  16. | extra_dhcp_opts       |                                                                                                                    |  
  17. | fixed_ips             | {"subnet_id": "aba7f133-8a02-41a1-9fec-4b26dac82503", "ip_address": "192.168.91.106"}                              |  
  18. | id                    | 0b7755a1-70a2-4b3c-84a1-cdbe945b0f0b                                                                               |  
  19. | mac_address           | fa:16:3e:3e:86:1b                                                                                                  |  
  20. | name                  |                                                                                                                    |  
  21. | network_id            | d8bfeca0-2273-4c7c-8872-a5baf5100600                                                                               |  
  22. | port_security_enabled | False                                                                                                              |  
  23. | security_groups       |                                                                                                                    |  
  24. | status                | DOWN                                                                                                             |  
  25. | tenant_id             |                                                                                                                    |  
  26. +-----------------------+--------------------------------------------------------------------------------------------------------------------+  
查看router网络命名空间,发现没有到external的路由网关 
  1. ip netns  
  2. qrouter-a9fd9767-2c15-4eb6-8c76-49dcce18fc7f  
  3. qdhcp-9fad5a29-6944-4dd9-85e6-16571775082f  
  4. qdhcp-d8bfeca0-2273-4c7c-8872-a5baf5100600  
  5. qdhcp-de942cde-e0c7-4d91-8aa9-3496ec86ba8c  

 

  1. ip netns exec qrouter-a9fd9767-2c15-4eb6-8c76-49dcce18fc7f route -n  
  2. Kernel IP routing table  
  3. Destination     Gateway         Genmask         Flags Metric Ref    Use Iface  
  4. 172.16.1.0      0.0.0.0         255.255.255.0   U     0      0        0 qr-e55502e7-47  

2.问题解决
修改模块文件/lib/python2.7/site-packages/neutron/agent/Linux/ip_lib.py相应内容如下:

  1. ......  
  2.     @classmethod  
  3.     def get_namespaces(cls):  
  4.         output = cls._execute([], 'netns', ('list',))  
  5.         return [l.split()[0] for l in output.splitlines()]  
  6. ......  
  7.     def exists(self, name):  
  8.         output = self._parent._execute(  
  9.             ['o'], 'netns', ['list'],  
  10.             run_as_root=cfg.CONF.AGENT.use_helper_for_ns_read)  
  11.         for line in [l.split()[0] for l in output.splitlines()]:  
  12.             if name == line:  
  13.                 return True  
  14.         return False  
  15. ......  
目前官网已经修复此BUG,你也可以直接通过yum upgrade升级系统包iproute解决。
posted @ 2017-09-03 23:16  nakky  阅读(1382)  评论(0编辑  收藏  举报