You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by jo...@apache.org on 2020/08/07 03:53:45 UTC

[impala] 03/03: IMPALA-10044: Fix cleanup for bootstrap_toolchain.py failure case

This is an automated email from the ASF dual-hosted git repository.

joemcdonnell pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit bbec0443fcdabf5de6f7ae0e47595414503f30f0
Author: Joe McDonnell <jo...@cloudera.com>
AuthorDate: Wed Aug 5 14:02:30 2020 -0700

    IMPALA-10044: Fix cleanup for bootstrap_toolchain.py failure case
    
    If DownloadUnpackTarball::download()'s wget_and_unpack_package call
    hits an exception, the exception handler cleans up any created
    directories. Currently, it erroneously cleans up the directory where
    the tarballs are downloaded even when it is not a temporary directory.
    This would delete the entire toolchain.
    
    This fixes the cleanup to only delete that directory if it is a
    temporary directory.
    
    Testing:
     - Simulated exception from wget_and_unpack_package and verified
       behavior.
    
    Change-Id: Ia57f56b6717635af94247fce50b955c07a57d113
    Reviewed-on: http://gerrit.cloudera.org:8080/16294
    Reviewed-by: Laszlo Gaal <la...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 bin/bootstrap_toolchain.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bin/bootstrap_toolchain.py b/bin/bootstrap_toolchain.py
index 647fc00..5d59da1 100755
--- a/bin/bootstrap_toolchain.py
+++ b/bin/bootstrap_toolchain.py
@@ -182,7 +182,8 @@ class DownloadUnpackTarball(object):
       # Clean up any partially-unpacked result.
       if os.path.isdir(unpack_dir):
         shutil.rmtree(unpack_dir)
-      if os.path.isdir(download_dir):
+      # Only delete the download directory if it is a temporary directory
+      if download_dir != self.destination_basedir and os.path.isdir(download_dir):
         shutil.rmtree(download_dir)
       raise
     if self.makedir: