AMBARI-6288. ambari-server may kill INIT and SSHD process (in some specific scenarios) (dlysnichenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/58451d8a Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/58451d8a Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/58451d8a Branch: refs/heads/branch-1.6.1 Commit: 58451d8a682b618da45e9217f0f5271babcf954a Parents: 40d2d4d Author: Lisnichenko Dmitro <dlysniche...@hortonworks.com> Authored: Thu Jun 26 20:51:40 2014 +0300 Committer: Lisnichenko Dmitro <dlysniche...@hortonworks.com> Committed: Thu Jun 26 20:51:40 2014 +0300 ---------------------------------------------------------------------- ambari-server/src/main/python/ambari-server.py | 16 +++++++++------- ambari-server/src/main/python/setupAgent.py | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/58451d8a/ambari-server/src/main/python/ambari-server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/python/ambari-server.py b/ambari-server/src/main/python/ambari-server.py index 20ccba2..4d9a943 100755 --- a/ambari-server/src/main/python/ambari-server.py +++ b/ambari-server/src/main/python/ambari-server.py @@ -116,6 +116,7 @@ JAVA_SHARE_PATH = "/usr/share/java" SERVER_OUT_FILE = "/var/log/ambari-server/ambari-server.out" SERVER_LOG_FILE = "/var/log/ambari-server/ambari-server.log" BLIND_PASSWORD = "*****" +ROOT_FS_PATH = "/" # terminal styles BOLD_ON = '\033[1m' @@ -1404,7 +1405,7 @@ def execute_remote_script(args, scriptPath): # args.warnings.append('{0} not found. Please, run DDL script manually'.format(DATABASE_CLI_TOOLS[DATABASE_INDEX])) if VERBOSE: print_warning_msg('{0} not found'.format(DATABASE_CLI_TOOLS[DATABASE_INDEX])) - return -1, "Client wasn't found", "Client wasn't found" + return -1, "Client wasn't found", "Client wasn't found" CMD = get_remote_script_line(args, scriptPath, False) if CMD: retcode, out, err = run_in_shell(CMD) @@ -1418,7 +1419,7 @@ def get_remote_script_line(args, scriptPath, forPrint=True): if not tool: # args.warnings.append('{0} not found. Please, run DDL script manually'.format(DATABASE_CLI_TOOLS[DATABASE_INDEX])) if VERBOSE or args.persistence_type == "remote": - print_warning_msg('{0} not found'.format(DATABASE_CLI_TOOLS[DATABASE_INDEX])) + print_warning_msg('{0} not found'.format(DATABASE_CLI_TOOLS[DATABASE_INDEX])) return None if args.dbms == "postgres": os.environ["PGPASSWORD"] = args.database_password @@ -2392,7 +2393,7 @@ def reset(args): check_database_name_property() parse_properties_file(args) - + if args.persistence_type == "remote": client_usage_cmd_drop = get_remote_script_line(args, DATABASE_DROP_SCRIPTS[DATABASE_INDEX]) client_usage_cmd_init = get_remote_script_line(args, DATABASE_INIT_SCRIPTS[DATABASE_INDEX]) @@ -2572,19 +2573,20 @@ def start(args): command_base.format(jdk_path, conf_dir, get_ambari_classpath(), - pidfile, os.path.join(PID_DIR, EXITCODE_NAME)) ) if not os.path.exists(PID_DIR): os.makedirs(PID_DIR, 0755) - #For properly daemonization server should be started using shell as parent + # required to start properly server instance + os.chdir(ROOT_FS_PATH) + + #For properly daemonization server should be started using shell as parent if is_root() and ambari_user != "root": # To inherit exported environment variables (especially AMBARI_PASSPHRASE), # from subprocess, we have to skip --login option of su command. That's why # we change dir to / (otherwise subprocess can face with 'permission denied' # errors while trying to list current directory - os.chdir("/") param_list = [utils.locate_file('su', '/bin'), ambari_user, "-s", utils.locate_file('sh', '/bin'), "-c", command] else: param_list = [utils.locate_file('sh', '/bin'), "-c", command] @@ -2643,7 +2645,7 @@ def upgrade_stack(args, stack_id, repo_url=None, repo_url_os=None): if not retcode == 0: raise FatalException(retcode, 'Stack upgrade failed.') - + return retcode http://git-wip-us.apache.org/repos/asf/ambari/blob/58451d8a/ambari-server/src/main/python/setupAgent.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/python/setupAgent.py b/ambari-server/src/main/python/setupAgent.py index 1fad46a..e83ed3f 100755 --- a/ambari-server/src/main/python/setupAgent.py +++ b/ambari-server/src/main/python/setupAgent.py @@ -200,9 +200,9 @@ def main(argv=None): retcode = getOptimalVersion("") else: retcode = getOptimalVersion(projectVersion) - + tryStopAgent() - + if retcode["exitstatus"] == 0 and retcode["log"] != None and retcode["log"] != "" and retcode["log"][0].strip() != "": availiableProjectVersion = retcode["log"].strip() if not isAgentPackageAlreadyInstalled(availiableProjectVersion):