Add retry logic when deleting logical port and logical switch

When deleting a logical port or logical switch, the backend may
have transient inconsistency due to split internal update transactions.
For now, adding the retry logical at the plugin side to solve
this problem.

Change-Id: I008d5759d490bbd364731f94b916c179af50491b
(cherry picked from commit 28ac8ed890)
This commit is contained in:
Shih-Hao Li 2016-01-27 10:12:46 -08:00 committed by garyk
parent 66a2716e2c
commit 59853cfd7e
2 changed files with 5 additions and 0 deletions

View File

@ -91,6 +91,8 @@ def create_logical_switch(display_name, transport_zone_id, tags,
return client.create_resource(resource, body)
@utils.retry_upon_exception_nsxv3(nsx_exc.StaleRevision,
max_attempts=cfg.CONF.nsx_v3.retries)
def delete_logical_switch(lswitch_id):
resource = 'logical-switches/%s?detach=true&cascade=true' % lswitch_id
client.delete_resource(resource)

View File

@ -258,6 +258,9 @@ class LogicalPort(AbstractRESTResource):
attachment=attachment))
return self._client.create(body=body)
@utils.retry_upon_exception_nsxv3(
nsx_exc.StaleRevision,
max_attempts=cfg.CONF.nsx_v3.retries)
def delete(self, lport_id):
return self._client.url_delete('%s?detach=true' % lport_id)