AMBARI-19203. LLAP app package cleanup fails after Hive Interactive start failure in non-root (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0d2ceecd Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0d2ceecd Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0d2ceecd Branch: refs/heads/branch-2.5 Commit: 0d2ceecd2a3bceca26d783ad5db8b78472c83708 Parents: 10cb81a Author: Andrew Onishuk <aonis...@hortonworks.com> Authored: Wed Dec 14 20:07:42 2016 +0200 Committer: Andrew Onishuk <aonis...@hortonworks.com> Committed: Wed Dec 14 20:07:42 2016 +0200 ---------------------------------------------------------------------- .../package/scripts/hive_server_interactive.py | 25 ++++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/0d2ceecd/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_server_interactive.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_server_interactive.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_server_interactive.py index 055c690..f2f0554 100644 --- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_server_interactive.py +++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_server_interactive.py @@ -31,7 +31,7 @@ from resource_management.libraries.script.script import Script from resource_management.libraries.functions import format from resource_management.libraries.functions.check_process_status import check_process_status from resource_management.core.source import InlineTemplate -from resource_management.core.resources.system import Execute +from resource_management.core.resources.system import Execute, Directory # Imports needed for Rolling/Express Upgrade from resource_management.libraries.functions import StackFeature @@ -345,12 +345,11 @@ class HiveServerInteractiveDefault(HiveServerInteractive): except: # Attempt to clean up the packaged application, or potentially rename it with a .bak if run_file_path is not None and cleanup: - try: - parent_dir = os.path.dirname(run_file_path) - if os.path.isdir(parent_dir): - shutil.rmtree(parent_dir) - except Exception, e: - Logger.error("Could not cleanup LLAP app package. Error: " + str(e)) + parent_dir = os.path.dirname(run_file_path) + Directory(parent_dir, + action = "delete", + ignore_failures = True, + ) # throw the original exception raise @@ -376,14 +375,14 @@ class HiveServerInteractiveDefault(HiveServerInteractive): if file_names: for path in file_names: abs_path = Script.get_tmp_dir()+"/"+path - if os.path.isdir(abs_path): - shutil.rmtree(abs_path) - Logger.info("Deleted previous run 'LLAP package' folder : {0}".format(abs_path)) + Directory(abs_path, + action = "delete", + ignore_failures = True + ) else: Logger.info("No '{0}*' folder deleted.".format(llap_package_folder_name_prefix)) - except Exception as e: - Logger.info("Exception while doing cleanup for past 'LLAP package(s)'.") - traceback.print_exc() + except: + Logger.exception("Exception while doing cleanup for past 'LLAP package(s)':")