From c1c22c81e7910485acac29bb1634ad4010d04ecc Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Thu, 16 Nov 2023 18:27:23 -0500 Subject: [PATCH] Ensure script cleanup is done in chroot --- api-daemon/pvcapid/vmbuilder.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api-daemon/pvcapid/vmbuilder.py b/api-daemon/pvcapid/vmbuilder.py index b6d58d7e..cd401cab 100755 --- a/api-daemon/pvcapid/vmbuilder.py +++ b/api-daemon/pvcapid/vmbuilder.py @@ -681,9 +681,15 @@ def create_vm( def fail_clean(celery, msg, exception=ProvisioningError): try: - vm_builder.cleanup() + with chroot(temp_dir): + vm_builder.cleanup() + except Exception: + # We're already failing, do the best we can + pass + try: general_cleanup() except Exception: + # We're already failing, do the best we can pass fail(celery, msg, exception=exception)