From ce621cfc804fb3f943b1d6d4304cd9e9da1ca06d Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Mon, 17 Apr 2023 00:45:08 -0700 Subject: [PATCH] Tier-1: Retry when removing edge cluster Retry operation is a StaleRevision error is returned from the backend. Change-Id: I637b9d1e6a23767d9297cec115cceaa573257329 --- vmware_nsxlib/v3/policy/core_resources.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/vmware_nsxlib/v3/policy/core_resources.py b/vmware_nsxlib/v3/policy/core_resources.py index 9a7f8196..baf27507 100644 --- a/vmware_nsxlib/v3/policy/core_resources.py +++ b/vmware_nsxlib/v3/policy/core_resources.py @@ -1317,12 +1317,19 @@ class NsxPolicyTier1Api(NsxPolicyResourceBase): def remove_edge_cluster(self, tier1_id, tenant=constants.POLICY_INFRA_TENANT): """Reset the path in the locale-service (deleting it is not allowed)""" - t1service_def = core_defs.Tier1LocaleServiceDef( - tier1_id=tier1_id, - service_id=self._locale_service_id(tier1_id), - edge_cluster_path="", - tenant=tenant) - self.policy_api.create_or_update(t1service_def) + + @utils.retry_upon_exception( + exceptions.StaleRevision, + max_attempts=self.policy_api.client.max_attempts) + def do_remove_edge_cluster(tier1_id, tenant): + t1service_def = core_defs.Tier1LocaleServiceDef( + tier1_id=tier1_id, + service_id=self._locale_service_id(tier1_id), + edge_cluster_path="", + tenant=tenant) + self.policy_api.create_or_update(t1service_def) + + do_remove_edge_cluster(tier1_id, tenant) def get_edge_cluster_path(self, tier1_id, tenant=constants.POLICY_INFRA_TENANT):