1. 程式人生 > >[BUG] Neutron建立虛擬路由器,埠狀態為down,設定路由閘道器未生效

[BUG] Neutron建立虛擬路由器,埠狀態為down,設定路由閘道器未生效

Openstack版本:Liberty

系統平臺:CentOS 7.2 64bit

網路模型:VLAN(external)+VXLAN(private)

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

1.現象

建立虛擬路由器,將子閘道器聯上去,並設定到external的路由閘道器

neutron router-create router
neutron router-interface-add router private
neutron router-gateway-set router provider-91
檢視路由埠
neutron router-port-list router
+--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+
| id                                   | name | mac_address       | fixed_ips                                                                             |
+--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+
| 0b7755a1-70a2-4b3c-84a1-cdbe945b0f0b |      | fa:16:3e:3e:86:1b | {"subnet_id": "aba7f133-8a02-41a1-9fec-4b26dac82503", "ip_address": "192.168.91.106"} |
| e55502e7-4779-4c03-9468-dbe401bcb876 |      | fa:16:3e:3f:6f:49 | {"subnet_id": "1a04665d-92a2-416d-aaea-c68455ee3fe3", "ip_address": "172.16.1.1"}     |
+--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+
在external測試路由閘道器IP發現不通,檢視路由閘道器埠發現狀態為DOWN,如下:
neutron port-list
+--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+
| id                                   | name | mac_address       | fixed_ips                                                                             |
+--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+
| 0b7755a1-70a2-4b3c-84a1-cdbe945b0f0b |      | fa:16:3e:3e:86:1b | {"subnet_id": "aba7f133-8a02-41a1-9fec-4b26dac82503", "ip_address": "192.168.91.106"} |
| 11265aeb-2e5b-490a-9c02-5e29c59fb73d |      | fa:16:3e:63:61:c1 | {"subnet_id": "aba7f133-8a02-41a1-9fec-4b26dac82503", "ip_address": "192.168.91.100"} |
| 1a2261d2-b5c0-4503-b0ce-8dab7690d96a |      | fa:16:3e:90:fa:0b | {"subnet_id": "aba7f133-8a02-41a1-9fec-4b26dac82503", "ip_address": "192.168.91.105"} |
| 2f41bf61-9679-4677-99bc-45cc18ff05cc |      | fa:16:3e:f8:dc:09 | {"subnet_id": "c4347434-781c-4c1c-b8b8-a963b5e80b77", "ip_address": "192.168.91.80"}  |
| 30095087-8c71-4fba-88ce-af0887b8e091 |      | fa:16:3e:31:d3:6a | {"subnet_id": "aba7f133-8a02-41a1-9fec-4b26dac82503", "ip_address": "192.168.91.101"} |
| 4b011b62-77cb-4642-9bcf-b80a9296c703 |      | fa:16:3e:ce:ee:a9 | {"subnet_id": "1a04665d-92a2-416d-aaea-c68455ee3fe3", "ip_address": "172.16.1.2"}     |
| 6470514b-c1e9-4d6e-88b3-22dde2f00fca |      | fa:16:3e:a2:d5:55 | {"subnet_id": "aba7f133-8a02-41a1-9fec-4b26dac82503", "ip_address": "192.168.91.104"} |
| 8e1802f6-1d68-4511-8232-781f0451ea15 |      | fa:16:3e:84:b7:b8 | {"subnet_id": "c4347434-781c-4c1c-b8b8-a963b5e80b77", "ip_address": "192.168.91.81"}  |
| a6c31bc9-7ee0-46da-943a-9836270a9801 |      | fa:16:3e:9e:0a:00 | {"subnet_id": "1a04665d-92a2-416d-aaea-c68455ee3fe3", "ip_address": "172.16.1.3"}     |
| e55502e7-4779-4c03-9468-dbe401bcb876 |      | fa:16:3e:3f:6f:49 | {"subnet_id": "1a04665d-92a2-416d-aaea-c68455ee3fe3", "ip_address": "172.16.1.1"}     |
+--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+

neutron port-show 0b7755a1-70a2-4b3c-84a1-cdbe945b0f0b
+-----------------------+--------------------------------------------------------------------------------------------------------------------+
| Field                 | Value                                                                                                              |
+-----------------------+--------------------------------------------------------------------------------------------------------------------+
| admin_state_up        | True                                                                                                               |
| allowed_address_pairs |                                                                                                                    |
| binding:host_id       | controller                                                                                                         |
| binding:profile       | {}                                                                                                                 |
| binding:vif_details   | {"port_filter": true, "ovs_hybrid_plug": true}                                                                     |
| binding:vif_type      | ovs                                                                                                                |
| binding:vnic_type     | normal                                                                                                             |
| device_id             | a9fd9767-2c15-4eb6-8c76-49dcce18fc7f                                                                               |
| device_owner          | network:router_gateway                                                                                             |
| dns_assignment        | {"hostname": "host-192-168-91-106", "ip_address": "192.168.91.106", "fqdn": "host-192-168-91-106.openstacklocal."} |
| dns_name              |                                                                                                                    |
| extra_dhcp_opts       |                                                                                                                    |
| fixed_ips             | {"subnet_id": "aba7f133-8a02-41a1-9fec-4b26dac82503", "ip_address": "192.168.91.106"}                              |
| id                    | 0b7755a1-70a2-4b3c-84a1-cdbe945b0f0b                                                                               |
| mac_address           | fa:16:3e:3e:86:1b                                                                                                  |
| name                  |                                                                                                                    |
| network_id            | d8bfeca0-2273-4c7c-8872-a5baf5100600                                                                               |
| port_security_enabled | False                                                                                                              |
| security_groups       |                                                                                                                    |
| status                | DOWN                                                                                                             |
| tenant_id             |                                                                                                                    |
+-----------------------+--------------------------------------------------------------------------------------------------------------------+
檢視router網路名稱空間,發現沒有到external的路由閘道器
ip netns
qrouter-a9fd9767-2c15-4eb6-8c76-49dcce18fc7f
qdhcp-9fad5a29-6944-4dd9-85e6-16571775082f
qdhcp-d8bfeca0-2273-4c7c-8872-a5baf5100600
qdhcp-de942cde-e0c7-4d91-8aa9-3496ec86ba8c
ip netns exec qrouter-a9fd9767-2c15-4eb6-8c76-49dcce18fc7f route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
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相應內容如下:

......
    @classmethod
    def get_namespaces(cls):
        output = cls._execute([], 'netns', ('list',))
        return [l.split()[0] for l in output.splitlines()]
......
    def exists(self, name):
        output = self._parent._execute(
            ['o'], 'netns', ['list'],
            run_as_root=cfg.CONF.AGENT.use_helper_for_ns_read)
        for line in [l.split()[0] for l in output.splitlines()]:
            if name == line:
                return True
        return False
......
目前官網已經修復此BUG,你也可以直接通過yum upgrade升級系統包iproute解決。