NSXv3: Add error handling for SQL timeout case
After the plugin added a DHCP static binding for a new neutron port in NSX backend, if it failed to store the binding info in neutron DB due to SQL timeout, neutron will delete this port. In this case, the backend entry is still there. So the plugin need to catch the timeout exception and clean the backend entry. Change-Id: I4ec93792bce67739dc73aa8a309d4291a54a8b64
This commit is contained in:
parent
921ff894a3
commit
0c5a40d8b6
@ -68,6 +68,7 @@ from oslo_log import log
|
|||||||
from oslo_utils import excutils
|
from oslo_utils import excutils
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
|
from sqlalchemy import exc as sql_exc
|
||||||
|
|
||||||
from vmware_nsx._i18n import _, _LE, _LI, _LW
|
from vmware_nsx._i18n import _, _LE, _LI, _LW
|
||||||
from vmware_nsx.api_replay import utils as api_replay_utils
|
from vmware_nsx.api_replay import utils as api_replay_utils
|
||||||
@ -982,7 +983,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||||||
nsx_db.add_neutron_nsx_service_binding(
|
nsx_db.add_neutron_nsx_service_binding(
|
||||||
context.session, network['id'], neutron_port['id'],
|
context.session, network['id'], neutron_port['id'],
|
||||||
nsxlib_consts.SERVICE_DHCP, dhcp_server['id'])
|
nsxlib_consts.SERVICE_DHCP, dhcp_server['id'])
|
||||||
except db_exc.DBError:
|
except (db_exc.DBError, sql_exc.TimeoutError):
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
LOG.error(_LE("Failed to create mapping for DHCP port %s,"
|
LOG.error(_LE("Failed to create mapping for DHCP port %s,"
|
||||||
"deleting port and logical DHCP server"),
|
"deleting port and logical DHCP server"),
|
||||||
@ -1586,7 +1587,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||||||
context.session, port['id'], fixed_ip['subnet_id'],
|
context.session, port['id'], fixed_ip['subnet_id'],
|
||||||
fixed_ip['ip_address'], dhcp_service['nsx_service_id'],
|
fixed_ip['ip_address'], dhcp_service['nsx_service_id'],
|
||||||
binding['id'])
|
binding['id'])
|
||||||
except db_exc.DBError:
|
except (db_exc.DBError, sql_exc.TimeoutError):
|
||||||
LOG.error(_LE("Failed to add mapping of DHCP binding "
|
LOG.error(_LE("Failed to add mapping of DHCP binding "
|
||||||
"%(binding)s for port %(port)s, deleting"
|
"%(binding)s for port %(port)s, deleting"
|
||||||
"DHCP binding on server"),
|
"DHCP binding on server"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user