Retry DHCP server deletion

In some cases deletion might fail because a segment port
is still reported as attached.

This change will ensure the operation is retried so it
eventually succeeds.

Change-Id: Ic40f8162f127414653ebeebca4cae5481b01585f
This commit is contained in:
Salvatore Orlando 2021-11-19 04:11:10 -08:00 committed by Salvatore Orlando
parent 28c2078e4d
commit 5a80f1d59c
1 changed files with 6 additions and 1 deletions

View File

@ -1773,6 +1773,11 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
LOG.error('Unable to create DHCP bindings for existing ports ' LOG.error('Unable to create DHCP bindings for existing ports '
'on subnet %s', subnet['id']) 'on subnet %s', subnet['id'])
@nsxlib_utils.retry_upon_exception(
Exception, max_attempts=cfg.CONF.nsx_v3.retries)
def _safe_delete_dhcp_server(self, nsx_service_id):
self.nsxlib.dhcp_server.delete(nsx_service_id)
def _disable_native_dhcp(self, context, network_id): def _disable_native_dhcp(self, context, network_id):
# Disable native DHCP service on the backend for this network. # Disable native DHCP service on the backend for this network.
# First delete the DHCP port in this network. Then delete the # First delete the DHCP port in this network. Then delete the
@ -1802,7 +1807,7 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
network_id) network_id)
try: try:
self.nsxlib.dhcp_server.delete(dhcp_service['nsx_service_id']) self._safe_delete_dhcp_server(dhcp_service['nsx_service_id'])
LOG.debug("Deleted logical DHCP server %(server)s for network " LOG.debug("Deleted logical DHCP server %(server)s for network "
"%(network)s", "%(network)s",
{'server': dhcp_service['nsx_service_id'], {'server': dhcp_service['nsx_service_id'],