← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1997492] [NEW] Neutron server doesn't wait for port DHCP provisioning while VM creation

 

Public bug reported:

I found that neutron-server does not wait for successful port provisioning from the dhcp agent in the case of VM creation. DHCP entity is not added into provisioning_block by neutron-server for such port.
As a result, nova receives a notification that the port is plugged, while the DHCP agent is still processing the port or even getting an error during processing.

Steps to reproduce on devstack from master:

- make port_create_end method fail in DHCP agent side [1]
- create a VM with network with DHCP enabled

VM is successfully created, port is active, while the DHCP entry for
this port is not configured.

[root@node0 neutron]# git diff
diff --git a/neutron/agent/dhcp/agent.py b/neutron/agent/dhcp/agent.py
index 7349d7e297..553ba81fdc 100644
--- a/neutron/agent/dhcp/agent.py
+++ b/neutron/agent/dhcp/agent.py
@@ -676,6 +676,7 @@ class DhcpAgent(manager.Manager):
                                     payload.get('priority', DEFAULT_PRIORITY),
                                     action='_port_create',
                                     resource=created_port, obj_type='port')
+        raise Exception('fail for testing purposes')
         self._queue.add(update)

     @_wait_if_syncing
     
     
[root@node0 neutron]# openstack server create test-vm --network net1 --flavor m1.tiny --image cirros-0.5.2-x86_64-disk
[root@node0 ~]# openstack server list
+--------------------------------------+---------+--------+--------------------+--------------------------+---------+
| ID                                   | Name    | Status | Networks           | Image                    | Flavor  |
+--------------------------------------+---------+--------+--------------------+--------------------------+---------+
| cce75084-b1e0-4407-a0d6-0074ed05abad | test-vm | ACTIVE | net1=192.168.1.111 | cirros-0.5.2-x86_64-disk | m1.tiny |
+--------------------------------------+---------+--------+--------------------+--------------------------+---------+
[root@node0 ~]# openstack port list --device-id cce75084-b1e0-4407-a0d6-0074ed05abad
+--------------------------------------+------+-------------------+------------------------------------------------------------------------------+--------+
| ID                                   | Name | MAC Address       | Fixed IP Addresses                                                           | Status |
+--------------------------------------+------+-------------------+------------------------------------------------------------------------------+--------+
| d7e55e08-05ae-4ac4-8cd0-4f88b93c5872 |      | fa:16:3e:9e:30:b3 | ip_address='192.168.1.111', subnet_id='281f70f3-8996-436b-ab90-bff1f9dbf5f8' | ACTIVE |
+--------------------------------------+------+-------------------+------------------------------------------------------------------------------+--------+
[root@node0 ~]#
[root@node0 ~]# cat /opt/stack/data/neutron/dhcp/710bcfcd-44d9-445d-a895-8ec522f64016/addn_hosts
[root@node0 ~]#


While VM creation there two API calls from the nova:
1) Port 'create' API call:
Nov 22 16:19:40 node0 neutron-server[953593]: DEBUG neutron.api.v2.base [req-5cbe6387-fe21-4509-81f6-cfcfe268252f req-0b7496ea-3697-4bc8-abb4-95d8f23d3497 demo admin] Request body: {'port': {'device_id': 'cce75084-b1e0-4407-a0d6-0074ed05abad', 'network_id': '710bcfcd-44d9-445d-a895-8ec522f64016', 'admin_state_up': True, 'tenant_id': 'a022c969871149e9b19ec31c896a0701'}} {{(pid=953593) prepare_request_body /opt/stack/neutron/neutron/api/v2/base.py:730}}

2) Port 'update' API call:
Nov 22 16:16:11 node0 neutron-server[953593]: DEBUG neutron.api.v2.base [req-145264e0-96a0-450b-9ad5-a5181c2497b1 req-9015e2c3-7dbb-430f-9cba-c7d6972f5134 service neutron] Request body: {'port': {'device_id': '4a4f87c0-a357-49eb-8639-58b499b8ae1f', 'device_owner': 'compute:nova', 'binding:host_id': 'node1'}} {{(pid=953593) prepare_request_body /opt/stack/neutron/neutron/api/v2/base.py:730}}

For the port creation API call a DHCP provisioning is not setup because device_owner is absent [2]
For the port 'update' API call a DCHP provisioning is not setup because none of the fixed_ips/mac_address is updated [3]

[1] https://opendev.org/openstack/neutron/src/commit/51827d8e78db4926f3aa347c4b2237a7b210f861/neutron/agent/dhcp/agent.py#L670
[2] https://opendev.org/openstack/neutron/src/commit/51827d8e78db4926f3aa347c4b2237a7b210f861/neutron/plugins/ml2/plugin.py#L1501
[3] https://opendev.org/openstack/neutron/src/commit/51827d8e78db4926f3aa347c4b2237a7b210f861/neutron/plugins/ml2/plugin.py#L1925

** Affects: neutron
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1997492

Title:
  Neutron server doesn't wait for port DHCP provisioning while VM
  creation

Status in neutron:
  New

Bug description:
  I found that neutron-server does not wait for successful port provisioning from the dhcp agent in the case of VM creation. DHCP entity is not added into provisioning_block by neutron-server for such port.
  As a result, nova receives a notification that the port is plugged, while the DHCP agent is still processing the port or even getting an error during processing.

  Steps to reproduce on devstack from master:

  - make port_create_end method fail in DHCP agent side [1]
  - create a VM with network with DHCP enabled

  VM is successfully created, port is active, while the DHCP entry for
  this port is not configured.

  [root@node0 neutron]# git diff
  diff --git a/neutron/agent/dhcp/agent.py b/neutron/agent/dhcp/agent.py
  index 7349d7e297..553ba81fdc 100644
  --- a/neutron/agent/dhcp/agent.py
  +++ b/neutron/agent/dhcp/agent.py
  @@ -676,6 +676,7 @@ class DhcpAgent(manager.Manager):
                                       payload.get('priority', DEFAULT_PRIORITY),
                                       action='_port_create',
                                       resource=created_port, obj_type='port')
  +        raise Exception('fail for testing purposes')
           self._queue.add(update)

       @_wait_if_syncing
       
       
  [root@node0 neutron]# openstack server create test-vm --network net1 --flavor m1.tiny --image cirros-0.5.2-x86_64-disk
  [root@node0 ~]# openstack server list
  +--------------------------------------+---------+--------+--------------------+--------------------------+---------+
  | ID                                   | Name    | Status | Networks           | Image                    | Flavor  |
  +--------------------------------------+---------+--------+--------------------+--------------------------+---------+
  | cce75084-b1e0-4407-a0d6-0074ed05abad | test-vm | ACTIVE | net1=192.168.1.111 | cirros-0.5.2-x86_64-disk | m1.tiny |
  +--------------------------------------+---------+--------+--------------------+--------------------------+---------+
  [root@node0 ~]# openstack port list --device-id cce75084-b1e0-4407-a0d6-0074ed05abad
  +--------------------------------------+------+-------------------+------------------------------------------------------------------------------+--------+
  | ID                                   | Name | MAC Address       | Fixed IP Addresses                                                           | Status |
  +--------------------------------------+------+-------------------+------------------------------------------------------------------------------+--------+
  | d7e55e08-05ae-4ac4-8cd0-4f88b93c5872 |      | fa:16:3e:9e:30:b3 | ip_address='192.168.1.111', subnet_id='281f70f3-8996-436b-ab90-bff1f9dbf5f8' | ACTIVE |
  +--------------------------------------+------+-------------------+------------------------------------------------------------------------------+--------+
  [root@node0 ~]#
  [root@node0 ~]# cat /opt/stack/data/neutron/dhcp/710bcfcd-44d9-445d-a895-8ec522f64016/addn_hosts
  [root@node0 ~]#

  
  While VM creation there two API calls from the nova:
  1) Port 'create' API call:
  Nov 22 16:19:40 node0 neutron-server[953593]: DEBUG neutron.api.v2.base [req-5cbe6387-fe21-4509-81f6-cfcfe268252f req-0b7496ea-3697-4bc8-abb4-95d8f23d3497 demo admin] Request body: {'port': {'device_id': 'cce75084-b1e0-4407-a0d6-0074ed05abad', 'network_id': '710bcfcd-44d9-445d-a895-8ec522f64016', 'admin_state_up': True, 'tenant_id': 'a022c969871149e9b19ec31c896a0701'}} {{(pid=953593) prepare_request_body /opt/stack/neutron/neutron/api/v2/base.py:730}}

  2) Port 'update' API call:
  Nov 22 16:16:11 node0 neutron-server[953593]: DEBUG neutron.api.v2.base [req-145264e0-96a0-450b-9ad5-a5181c2497b1 req-9015e2c3-7dbb-430f-9cba-c7d6972f5134 service neutron] Request body: {'port': {'device_id': '4a4f87c0-a357-49eb-8639-58b499b8ae1f', 'device_owner': 'compute:nova', 'binding:host_id': 'node1'}} {{(pid=953593) prepare_request_body /opt/stack/neutron/neutron/api/v2/base.py:730}}

  For the port creation API call a DHCP provisioning is not setup because device_owner is absent [2]
  For the port 'update' API call a DCHP provisioning is not setup because none of the fixed_ips/mac_address is updated [3]

  [1] https://opendev.org/openstack/neutron/src/commit/51827d8e78db4926f3aa347c4b2237a7b210f861/neutron/agent/dhcp/agent.py#L670
  [2] https://opendev.org/openstack/neutron/src/commit/51827d8e78db4926f3aa347c4b2237a7b210f861/neutron/plugins/ml2/plugin.py#L1501
  [3] https://opendev.org/openstack/neutron/src/commit/51827d8e78db4926f3aa347c4b2237a7b210f861/neutron/plugins/ml2/plugin.py#L1925

To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1997492/+subscriptions