Merge "Account for unwire failures during OVS trunk rewiring operations"

This commit is contained in:
Jenkins 2017-01-04 13:20:38 +00:00 committed by Gerrit Code Review
commit 7c771abe0e
2 changed files with 23 additions and 2 deletions

View File

@ -379,21 +379,29 @@ class OVSDBHandler(object):
return
# We need to remove stale subports
unwire_status = constants.ACTIVE_STATUS
if rewire:
old_subport_ids = self.get_connected_subports_for_trunk(trunk.id)
subports = {p['port_id'] for p in trunk.sub_ports}
subports_to_delete = set(old_subport_ids) - subports
if subports_to_delete:
self.unwire_subports_for_trunk(trunk.id, subports_to_delete)
unwire_status = self.unwire_subports_for_trunk(
trunk.id, subports_to_delete)
# NOTE(status_police): inform the server whether the operation
# was a partial or complete success. Do not inline status.
# NOTE: in case of rewiring we readd ports that are already present on
# the bridge because e.g. the segmentation ID might have changed (e.g.
# agent crashed, port was removed and readded with a different seg ID)
status = self.wire_subports_for_trunk(
wire_status = self.wire_subports_for_trunk(
ctx, trunk.id, trunk.sub_ports,
trunk_bridge=trunk_br, parent_port=port)
if (unwire_status == wire_status and
wire_status == constants.ACTIVE_STATUS):
status = constants.ACTIVE_STATUS
else:
status = constants.DEGRADED_STATUS
self.report_trunk_status(ctx, trunk.id, status)
def _set_trunk_metadata(self, trunk_bridge, port, trunk_id, subport_ids):

View File

@ -257,6 +257,19 @@ class TestOVSDBHandler(base.BaseTestCase):
trunk_rpc.update_trunk_status.assert_called_once_with(
mock.ANY, mock.ANY, constants.ERROR_STATUS)
def test__wire_trunk_rewire_trunk_failure(self):
with mock.patch.object(self.ovsdb_handler,
'unwire_subports_for_trunk') as f,\
mock.patch.object(self.ovsdb_handler,
'get_connected_subports_for_trunk') as g:
g.return_value = ['stale_port']
f.return_value = constants.DEGRADED_STATUS
self.ovsdb_handler._wire_trunk(
mock.Mock(), self.fake_port, rewire=True)
trunk_rpc = self.ovsdb_handler.trunk_rpc
trunk_rpc.update_trunk_status.assert_called_once_with(
mock.ANY, mock.ANY, constants.DEGRADED_STATUS)
def test__wire_trunk_report_trunk_called_on_wiring(self):
with mock.patch.object(self.trunk_manager, 'create_trunk'),\
mock.patch.object(self.ovsdb_handler,