diff options
author | Alan Rominger <arominge@redhat.com> | 2021-07-13 19:49:09 +0200 |
---|---|---|
committer | Alan Rominger <arominge@redhat.com> | 2021-07-13 19:49:09 +0200 |
commit | 397fab793d40b19bdd32d18c4e77125690795e11 (patch) | |
tree | a3c2bdc2fcebc0e4a6d29ee65515a43ce596ce98 /awxkit | |
parent | Wait until inventory is fully deleted in silent_delete (diff) | |
download | awx-397fab793d40b19bdd32d18c4e77125690795e11.tar.xz awx-397fab793d40b19bdd32d18c4e77125690795e11.zip |
Avoid waiting for deletion in error cases
Diffstat (limited to 'awxkit')
-rw-r--r-- | awxkit/awxkit/api/pages/inventory.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/awxkit/awxkit/api/pages/inventory.py b/awxkit/awxkit/api/pages/inventory.py index fb3284ba3f..2142275886 100644 --- a/awxkit/awxkit/api/pages/inventory.py +++ b/awxkit/awxkit/api/pages/inventory.py @@ -5,6 +5,7 @@ import json from awxkit.api.pages import Credential, Organization, Project, UnifiedJob, UnifiedJobTemplate from awxkit.utils import filter_by_class, random_title, update_payload, not_provided, PseudoNamespace, poll_until from awxkit.api.mixins import DSAdapter, HasCreate, HasInstanceGroups, HasNotifications, HasVariables, HasCopy +from awxkit.config import config from awxkit.api.resources import resources import awxkit.exceptions as exc from . import base @@ -97,9 +98,18 @@ class Inventory(HasCopy, HasCreate, HasInstanceGroups, HasVariables, base.Base): poll_until(_wait, interval=1, timeout=60) def silent_delete(self): - r = super(Inventory, self).silent_delete() - self.wait_until_deleted() - return r + try: + if not config.prevent_teardown: + r = self.delete() + self.wait_until_deleted() + return r + except (exc.NoContent, exc.NotFound, exc.Forbidden): + pass + except (exc.BadRequest, exc.Conflict) as e: + if 'Resource is being used' in e.msg: + pass + else: + raise e def update_inventory_sources(self, wait=False): response = self.related.update_inventory_sources.post() |