From 28ac8ed890652facdcea9dd4ce37c1f8aa998ac4 Mon Sep 17 00:00:00 2001 From: Shih-Hao Li Date: Wed, 27 Jan 2016 10:12:46 -0800 Subject: [PATCH] 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 --- vmware_nsx/nsxlib/v3/__init__.py | 2 ++ vmware_nsx/nsxlib/v3/resources.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/vmware_nsx/nsxlib/v3/__init__.py b/vmware_nsx/nsxlib/v3/__init__.py index 7bce8453d4..d5b555c5ed 100644 --- a/vmware_nsx/nsxlib/v3/__init__.py +++ b/vmware_nsx/nsxlib/v3/__init__.py @@ -90,6 +90,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) diff --git a/vmware_nsx/nsxlib/v3/resources.py b/vmware_nsx/nsxlib/v3/resources.py index b6f512b152..e531d7f103 100644 --- a/vmware_nsx/nsxlib/v3/resources.py +++ b/vmware_nsx/nsxlib/v3/resources.py @@ -261,6 +261,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)