Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ocp_resources/node_network_configuration_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def deploy(self):
return self
except Exception as e:
LOGGER.error(e)
self.clean_up()
super().__exit__(exception_type=None, exception_value=None, traceback=None)
raise

@property
Expand Down
10 changes: 10 additions & 0 deletions ocp_resources/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,16 @@ def __enter__(self):
return self.deploy()

def __exit__(self, exception_type, exception_value, traceback):
# For debug, export kind (class name) + NOTEARDOWN to skip resource teardown.
# For example:export VirtualMachineInstanceNOTEARDOWN=True
skip_teardown_env = f"{self.kind}NOTEARDOWN"
no_teardown_from_environment = os.environ.get(skip_teardown_env)
if no_teardown_from_environment:
LOGGER.warning(
f"Skip teardown. Got {skip_teardown_env}={no_teardown_from_environment}"
)
return

if self.teardown:
self.clean_up()

Expand Down