Reviewed: https://review.openstack.org/403568 Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=115cf068a6d48cdf8b0d20a3c5a779bb8120aa9b Submitter: Jenkins Branch: master
commit 115cf068a6d48cdf8b0d20a3c5a779bb8120aa9b Author: Kevin_Zheng <[email protected]> Date: Mon Nov 28 16:12:51 2016 +0800 Don't delete neutron port when attach failed Currently, when attaching neutron pre-existing port to an instance, if the attach failed, it will also be deleted in Neutron side due to bad judgement of the who created the port by reading not up-to-date info_cache. The workflow starts at: https://github.com/openstack/nova/blob/9ed0d6114/nova/network/neutronv2/api.py#L881 ordered_ports and preexisting_port_ids are the same when attaching a preexisting port to an instance and it calls https://github.com/openstack/nova/blob/9ed0d6114/nova/network/base_api.py#L246 which calls back into the neutronv2 api code https://github.com/openstack/nova/blob/9ed0d6114/nova/network/neutronv2/api.py#L1274 and at this point, compute_utils.refresh_info_cache_for_instance(context, instance) won't have the newly attached port in it(see debug log: http://paste.openstack.org/show/613232/) because _build_network_info_model() is going to process it. The instance obj in memoryt with old info_cache will be used at rollback process and causing the miss-judging. This patch fixed it by updating instance.info_cache to the new ic after it is created. Co-Authored-By: [email protected] Change-Id: Ib323b74d4ea1e874b476ab5addfc6bc79cb7c751 closes-bug: #1645175 ** Changed in: nova Status: In Progress => Fix Released -- You received this bug notification because you are a member of Yahoo! Engineering Team, which is subscribed to OpenStack Compute (nova). https://bugs.launchpad.net/bugs/1645175 Title: Neutron port got deleted when attach interface failed Status in OpenStack Compute (nova): Fix Released Status in OpenStack Compute (nova) newton series: Confirmed Status in OpenStack Compute (nova) ocata series: Confirmed Bug description: When attach an pre created Neutron port to Nova instances and got failed, the port will be deleted in Neutron: How to reproduce: Step 1: create a new Neutron Port: root@SZX1000191849:/opt/stack/nova# neutron port-create e1775804-7670-482c-bf1a-309fff85f598 Created a new port: +-----------------------+------------------------------------------------------------------------------------+ | Field | Value | +-----------------------+------------------------------------------------------------------------------------+ | admin_state_up | True | | allowed_address_pairs | | | binding:host_id | | | binding:profile | {} | | binding:vif_details | {} | | binding:vif_type | unbound | | binding:vnic_type | normal | | created_at | 2016-11-28T02:20:26Z | | description | | | device_id | | | device_owner | | | extra_dhcp_opts | | | fixed_ips | {"subnet_id": "6cf2ed09-8394-4e3e-81d5-3880fe1c6984", "ip_address": "172.24.4.2"} | | | {"subnet_id": "6b3902ca-deea-46f0-97e9-80c70243413e", "ip_address": "2001:db8::6"} | | id | fd240a85-53cb-467a-8e43-330bb5c928ab | | mac_address | fa:16:3e:cc:fb:9e | | name | | | network_id | e1775804-7670-482c-bf1a-309fff85f598 | | port_security_enabled | True | | project_id | 405a8b8100ae47ffaa89730681ee400f | | revision_number | 6 | | security_groups | 9ea518bb-ee12-489a-ac6a-3434d2c081c4 | | status | DOWN | | tenant_id | 405a8b8100ae47ffaa89730681ee400f | | updated_at | 2016-11-28T02:20:27Z | +-----------------------+------------------------------------------------------------------------------------+ root@SZX1000191849:/opt/stack/nova# neutron port-list +--------------------------------------+------+-------------------+-----------------------------------------------------------------------------------------+ | id | name | mac_address | fixed_ips | +--------------------------------------+------+-------------------+-----------------------------------------------------------------------------------------+ | 453879db-6bc2-4a40-89eb-588a15cf33c4 | | fa:16:3e:19:9e:27 | {"subnet_id": "ce211f7b-e808-4222-80e4-9bec9113afa3", "ip_address": "10.0.0.9"} | | | | | {"subnet_id": "5ff9100a-02ff-40a2-8c33-0f0d285b72ad", "ip_address": "2001:db8:8000::8"} | | 4cd1ad8e-86df-4454-a187-08bb3faa32ec | | fa:16:3e:60:b4:8f | {"subnet_id": "ce211f7b-e808-4222-80e4-9bec9113afa3", "ip_address": "10.0.0.13"} | | | | | {"subnet_id": "5ff9100a-02ff-40a2-8c33-0f0d285b72ad", "ip_address": "2001:db8:8000::5"} | | 74a0b31a-3a26-4b20-bdb2-0bb0d343c551 | | fa:16:3e:12:6b:9a | {"subnet_id": "6cf2ed09-8394-4e3e-81d5-3880fe1c6984", "ip_address": "172.24.4.10"} | | | | | {"subnet_id": "6b3902ca-deea-46f0-97e9-80c70243413e", "ip_address": "2001:db8::a"} | | 8fc6af24-78f8-4234-9a5a-c348ba873aff | | fa:16:3e:e3:25:62 | {"subnet_id": "ce211f7b-e808-4222-80e4-9bec9113afa3", "ip_address": "10.0.0.1"} | | eaf6a086-a146-4e45-8c4c-a54b209e80c4 | | fa:16:3e:5d:89:bd | {"subnet_id": "ce211f7b-e808-4222-80e4-9bec9113afa3", "ip_address": "10.0.0.2"} | | | | | {"subnet_id": "5ff9100a-02ff-40a2-8c33-0f0d285b72ad", "ip_address": "2001:db8:8000::2"} | | ebce0f96-984b-4890-bd6b-dc561973b615 | | fa:16:3e:da:1b:7f | {"subnet_id": "5ff9100a-02ff-40a2-8c33-0f0d285b72ad", "ip_address": "2001:db8:8000::1"} | | fd240a85-53cb-467a-8e43-330bb5c928ab | | fa:16:3e:cc:fb:9e | {"subnet_id": "6cf2ed09-8394-4e3e-81d5-3880fe1c6984", "ip_address": "172.24.4.2"} | | | | | {"subnet_id": "6b3902ca-deea-46f0-97e9-80c70243413e", "ip_address": "2001:db8::6"} | +--------------------------------------+------+-------------------+-----------------------------------------------------------------------------------------+ Step 2: Attach it to the Nova instance, and error is raised by intension root@SZX1000191849:/opt/stack/nova# nova interface-attach e1213eee-5378-472c-8f66-a35b7bdb09e3 --port-id fd240a85-53cb-467a-8e43-330bb5c928ab ERROR (ClientException): Failed to attach network adapter device to e1213eee-5378-472c-8f66-a35b7bdb09e3 (HTTP 500) (Request-ID: req-7ab972a5-91d7-49d9-96bc-f063cf4dd1f2) Step 3: Check the neutron ports again, the port is gone. root@SZX1000191849:/opt/stack/nova# neutron port-list +--------------------------------------+------+-------------------+-----------------------------------------------------------------------------------------+ | id | name | mac_address | fixed_ips | +--------------------------------------+------+-------------------+-----------------------------------------------------------------------------------------+ | 453879db-6bc2-4a40-89eb-588a15cf33c4 | | fa:16:3e:19:9e:27 | {"subnet_id": "ce211f7b-e808-4222-80e4-9bec9113afa3", "ip_address": "10.0.0.9"} | | | | | {"subnet_id": "5ff9100a-02ff-40a2-8c33-0f0d285b72ad", "ip_address": "2001:db8:8000::8"} | | 4cd1ad8e-86df-4454-a187-08bb3faa32ec | | fa:16:3e:60:b4:8f | {"subnet_id": "ce211f7b-e808-4222-80e4-9bec9113afa3", "ip_address": "10.0.0.13"} | | | | | {"subnet_id": "5ff9100a-02ff-40a2-8c33-0f0d285b72ad", "ip_address": "2001:db8:8000::5"} | | 74a0b31a-3a26-4b20-bdb2-0bb0d343c551 | | fa:16:3e:12:6b:9a | {"subnet_id": "6cf2ed09-8394-4e3e-81d5-3880fe1c6984", "ip_address": "172.24.4.10"} | | | | | {"subnet_id": "6b3902ca-deea-46f0-97e9-80c70243413e", "ip_address": "2001:db8::a"} | | 8fc6af24-78f8-4234-9a5a-c348ba873aff | | fa:16:3e:e3:25:62 | {"subnet_id": "ce211f7b-e808-4222-80e4-9bec9113afa3", "ip_address": "10.0.0.1"} | | eaf6a086-a146-4e45-8c4c-a54b209e80c4 | | fa:16:3e:5d:89:bd | {"subnet_id": "ce211f7b-e808-4222-80e4-9bec9113afa3", "ip_address": "10.0.0.2"} | | | | | {"subnet_id": "5ff9100a-02ff-40a2-8c33-0f0d285b72ad", "ip_address": "2001:db8:8000::2"} | | ebce0f96-984b-4890-bd6b-dc561973b615 | | fa:16:3e:da:1b:7f | {"subnet_id": "5ff9100a-02ff-40a2-8c33-0f0d285b72ad", "ip_address": "2001:db8:8000::1"} | +--------------------------------------+------+-------------------+-----------------------------------------------------------------------------------------+ This is due to when we do clean up here: http://git.openstack.org/cgit/openstack/nova/tree/nova/network/neutronv2/api.py#n1201 we treat this port as nova-created port as it has not been included in the preexisting ports. To manage notifications about this bug go to: https://bugs.launchpad.net/nova/+bug/1645175/+subscriptions -- Mailing list: https://launchpad.net/~yahoo-eng-team Post to : [email protected] Unsubscribe : https://launchpad.net/~yahoo-eng-team More help : https://help.launchpad.net/ListHelp

