Change OVS agent to update skipped port status to DOWN

When the OVS agent skips processing a port because it was
not found on the integration bridge, it doesn't send back
any status to the server to notify it.  This can cause the
port to get stuck in the BUILD state indefinitely, since
that is the default state it gets before the server tells
the agent to update it.

The OVS agent will now notify the server that any skipped
device should be considered DOWN if it did not exist.

Conflicts:
 neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py

Change-Id: I15dc55951cdb75c6d87d7c645f8e2cbf82b2f3e4
Closes-bug: #1719011
(cherry picked from commit a789d23b02)
This commit is contained in:
Brian Haley 2017-09-22 16:23:11 -04:00
parent d6645ad171
commit c6044fb861
2 changed files with 25 additions and 1 deletions

View File

@ -1596,6 +1596,17 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
LOG.debug("Device %s not defined on plugin", detail['device'])
return failed_devices
def treat_devices_skipped(self, devices):
LOG.info(_LI("Ports %s skipped, changing status to down"), devices)
devices_down = self.plugin_rpc.update_device_list(self.context,
[],
devices,
self.agent_id,
self.conf.host)
failed_devices = set(devices_down.get('failed_devices_down'))
if failed_devices:
LOG.debug("Port down failed for %s", failed_devices)
def process_network_ports(self, port_info, ovs_restarted):
failed_devices = {'added': set(), 'removed': set()}
# TODO(salv-orlando): consider a solution for ensuring notifications
@ -1649,6 +1660,13 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
"treat_devices_removed completed in %(elapsed).3f",
{'iter_num': self.iter_num,
'elapsed': time.time() - start})
if skipped_devices:
start = time.time()
self.treat_devices_skipped(skipped_devices)
LOG.debug("process_network_ports - iteration:%(iter_num)d - "
"treat_devices_skipped completed in %(elapsed).3f",
{'iter_num': self.iter_num,
'elapsed': time.time() - start})
return failed_devices
def process_ancillary_network_ports(self, port_info):

View File

@ -966,7 +966,11 @@ class TestOvsNeutronAgent(object):
"treat_devices_removed",
return_value=(
failed_devices[
'removed'])) as device_removed:
'removed'])) as device_removed,\
mock.patch.object(self.agent,
"treat_devices_skipped",
return_value=(
skipped_devices)) as device_skipped:
self.assertEqual(
failed_devices,
self.agent.process_network_ports(port_info, False))
@ -980,6 +984,8 @@ class TestOvsNeutronAgent(object):
devices_added_updated, False)
if port_info.get('removed', set()):
device_removed.assert_called_once_with(port_info['removed'])
if skipped_devices:
device_skipped.assert_called_once_with(set(skipped_devices))
def test_process_network_ports(self):
self._test_process_network_ports(