Retry on create-with-parent in NsxPendingDelete event

Change-Id: I4468e8ebf8b095c259e73021876badb885d47a0d
This commit is contained in:
Adit Sarfaty 2019-06-18 09:57:33 +03:00
parent 15743868fe
commit f4731dd9a5

View File

@ -294,18 +294,18 @@ class NsxPolicyResourceBase(object):
transaction.store_def(child_def, self.policy_api.client)
else:
# No transaction - apply now
if child_def:
self.policy_api.create_with_parent(policy_def, child_def)
else:
# in case the same object was just deleted, create may need to
# be retried
@utils.retry_upon_exception(
exceptions.NsxPendingDelete,
max_attempts=self.policy_api.client.max_attempts)
def _do_create_with_retry():
# in case the same object was just deleted, create may need to
# be retried
@utils.retry_upon_exception(
exceptions.NsxPendingDelete,
max_attempts=self.policy_api.client.max_attempts)
def _do_create_with_retry():
if child_def:
self.policy_api.create_with_parent(policy_def, child_def)
else:
self.policy_api.create_or_update(policy_def)
_do_create_with_retry()
_do_create_with_retry()
class NsxPolicyDomainApi(NsxPolicyResourceBase):
@ -2814,7 +2814,15 @@ class NsxPolicySecurityPolicyBaseApi(NsxPolicyResourceBase):
category=category, tags=tags,
map_sequence_number=map_sequence_number)
self.policy_api.create_with_parent(map_def, entries)
# in case the same object was just deleted, create may need to
# be retried
@utils.retry_upon_exception(
exceptions.NsxPendingDelete,
max_attempts=self.policy_api.client.max_attempts)
def _do_create_with_retry():
self.policy_api.create_with_parent(map_def, entries)
_do_create_with_retry()
return map_id
def create_entry(self, name, domain_id, map_id, entry_id=None,