Check for agent restarted after checking for DVR port
This is a stable-only fix since code around the change was removed in master: https://review.opendev.org/#/c/641866 Commita5244d6d44
changed the check order so regular non-dvr ports are checked for agent restarted. However regular ports may be unbound already, which leads to the error in the bug description: agent_restarted check is done against a 'None' agent. This patch fixed logic back - only check agent_restarted for dvr ports. This also adds some logging to have a clue why update port up/down fails. Change-Id: I3ad59864eeb42916d2cf15a5292d5aa9484f6e91 Closes-Bug: #1835731 (cherry picked from commitc3a3031f78
)
This commit is contained in:
parent
10191fd817
commit
2318a60046
|
@ -315,11 +315,13 @@ class RpcCallbacks(type_tunnel.TunnelRpcCallbackMixin):
|
|||
# and so we don't need to update it again here. But, l2pop did not
|
||||
# handle DVR ports while restart neutron-*-agent, we need to handle
|
||||
# it here.
|
||||
if agent_restarted is None:
|
||||
agent_restarted = l2pop_driver.obj.agent_restarted(port_context)
|
||||
if (port['device_owner'] == n_const.DEVICE_OWNER_DVR_INTERFACE and
|
||||
not agent_restarted):
|
||||
return
|
||||
if port['device_owner'] == n_const.DEVICE_OWNER_DVR_INTERFACE:
|
||||
if agent_restarted is None:
|
||||
agent_restarted = l2pop_driver.obj.agent_restarted(
|
||||
port_context)
|
||||
if not agent_restarted:
|
||||
return
|
||||
|
||||
port = port_context.current
|
||||
if (port['device_owner'] != n_const.DEVICE_OWNER_DVR_INTERFACE and
|
||||
status == n_const.PORT_STATUS_ACTIVE and
|
||||
|
@ -351,9 +353,9 @@ class RpcCallbacks(type_tunnel.TunnelRpcCallbackMixin):
|
|||
rpc_context,
|
||||
device=device,
|
||||
**kwargs)
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
failed_devices_up.append(device)
|
||||
LOG.error("Failed to update device %s up", device)
|
||||
LOG.error("Failed to update device %s up: %s", device, e)
|
||||
else:
|
||||
devices_up.append(device)
|
||||
|
||||
|
@ -365,9 +367,9 @@ class RpcCallbacks(type_tunnel.TunnelRpcCallbackMixin):
|
|||
rpc_context,
|
||||
device=device,
|
||||
**kwargs)
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
failed_devices_down.append(device)
|
||||
LOG.error("Failed to update device %s down", device)
|
||||
LOG.error("Failed to update device %s down: %s", device, e)
|
||||
else:
|
||||
devices_down.append(dev)
|
||||
|
||||
|
|
|
@ -249,6 +249,16 @@ class RpcCallbacksTestCase(base.BaseTestCase):
|
|||
mock.ANY, 'fake_port_id', constants.PORT_STATUS_DOWN,
|
||||
'fake_host')
|
||||
|
||||
def test_notify_l2pop_port_wiring_non_dvr_port(self):
|
||||
port = {'device_owner': constants.DEVICE_OWNER_COMPUTE_PREFIX}
|
||||
l2pop_driver = (
|
||||
self.plugin.mechanism_manager.mech_drivers.get.return_value)
|
||||
with mock.patch.object(ml2_db, 'get_port') as ml2_db_get_port:
|
||||
ml2_db_get_port.return_value = port
|
||||
self.callbacks.notify_l2pop_port_wiring(
|
||||
'port_id', mock.Mock(), 'DOWN', 'host', agent_restarted=None)
|
||||
self.assertFalse(l2pop_driver.obj.agent_restarted.called)
|
||||
|
||||
def test_update_device_down_call_update_port_status_failed(self):
|
||||
self.plugin.update_port_status.side_effect = exc.StaleDataError
|
||||
self.assertEqual({'device': 'fake_device', 'exists': False},
|
||||
|
|
Loading…
Reference in New Issue