Add retry on StaleRevision for transactions

Change-Id: I9bc9ae59833833f1c093de29b00a82b828f1935c
This commit is contained in:
asarfaty 2020-08-12 18:37:21 +02:00 committed by Adit Sarfaty
parent 24b15000ca
commit cc4bd57c67
2 changed files with 10 additions and 1 deletions

View File

@ -42,6 +42,7 @@ def http_error_to_exception(status_code, error_code):
'8327': exceptions.NsxOverlapVlan,
'500045': exceptions.NsxPendingDelete,
'500030': exceptions.ResourceInUse,
'500087': exceptions.StaleRevision,
'500105': exceptions.NsxOverlapAddresses,
'503040': exceptions.NsxSegemntWithVM,
'100148': exceptions.StaleRevision},

View File

@ -22,6 +22,7 @@ from vmware_nsxlib.v3 import exceptions
from vmware_nsxlib.v3.policy import constants
from vmware_nsxlib.v3.policy import core_defs
from vmware_nsxlib.v3 import utils
class NsxPolicyTransactionException(exceptions.NsxLibException):
@ -190,7 +191,14 @@ class NsxPolicyTransaction(object):
resource_def.get_delete()))
if body:
headers = {'nsx-enable-partial-patch': 'true'}
self.client.patch(url, body, headers=headers)
@utils.retry_upon_exception(
(exceptions.NsxPendingDelete, exceptions.StaleRevision),
max_attempts=self.client.max_attempts)
def _do_patch_with_retry():
self.client.patch(url, body, headers=headers)
_do_patch_with_retry()
@staticmethod
def get_current():