From 91eb3d8346a8964aa046d1e016d571056de868de Mon Sep 17 00:00:00 2001 From: LIU Yulong Date: Tue, 1 Dec 2020 17:13:52 +0800 Subject: [PATCH] Handle router HA port concurrently deleting Router HA port may be deleted concurrently while the plugin is trying to update. This patch catches the known exceptions. Should not `plugin.update_port_statuses` use because: 1. plugin.update_port_statuses will hide all exception no matter the port exists. 2. The code just needs to catch the port not found error, but let all other exception raised if port still exists. Closes-Bug: #1906375 Change-Id: Id5d9c99be3bd6854568d2b1baa86c25c0cfd4756 --- neutron/api/rpc/handlers/l3_rpc.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/neutron/api/rpc/handlers/l3_rpc.py b/neutron/api/rpc/handlers/l3_rpc.py index 5ecdb0c0a33..27557659bb9 100644 --- a/neutron/api/rpc/handlers/l3_rpc.py +++ b/neutron/api/rpc/handlers/l3_rpc.py @@ -25,6 +25,7 @@ from neutron_lib.plugins import directory from oslo_config import cfg from oslo_log import log as logging import oslo_messaging +from sqlalchemy import orm LOG = logging.getLogger(__name__) @@ -89,8 +90,13 @@ class L3RpcCallback(object): "setting HA network ports %(ha_ports)s status to DOWN.", {"host": host, "ha_ports": ha_ports}) for p in ha_ports: - self.plugin.update_port( - context, p, {'port': {'status': constants.PORT_STATUS_DOWN}}) + try: + self.plugin.update_port( + context, p, + {'port': {'status': constants.PORT_STATUS_DOWN}}) + except (orm.exc.StaleDataError, orm.exc.ObjectDeletedError, + exceptions.PortNotFound): + pass def get_router_ids(self, context, host): """Returns IDs of routers scheduled to l3 agent on