Retry policy create by PATCH in case of NsxPendingDelete error

In some cases, the same object with the same ID is created just
after it was deleted.
In this case the NSX might through NsxPendingDelete error, and
we should retry the creation.

Change-Id: Iefbfc88d2111fc12ed7242df4b77c83b9323c34c
This commit is contained in:
Adit Sarfaty 2019-05-12 14:07:48 +03:00
parent 4aeb0e43cb
commit 468c3effba

View File

@ -286,7 +286,15 @@ class NsxPolicyResourceBase(object):
if child_def:
self.policy_api.create_with_parent(policy_def, child_def)
else:
self.policy_api.create_or_update(policy_def)
# 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_or_update(policy_def)
_do_create_with_retry()
class NsxPolicyDomainApi(NsxPolicyResourceBase):