Repository: ambari Updated Branches: refs/heads/branch-2.5 a71626f67 -> 681adc095
Revert "Revert "AMBARI-20159. Cluster deploy failed as install service failed with "Execution of zypper clean --all returned 7. System management is locked by the application with pid ..."(vbrodetskyi)"" This reverts commit c4ecdeac80eac2002362cd92059bacc5dc4347c9. Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/681adc09 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/681adc09 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/681adc09 Branch: refs/heads/branch-2.5 Commit: 681adc0956fb460cfd8ed6b01c050d239a0eaf9e Parents: a71626f Author: Swapan Shridhar <[email protected]> Authored: Fri Feb 24 01:13:15 2017 -0800 Committer: Swapan Shridhar <[email protected]> Committed: Fri Feb 24 01:13:15 2017 -0800 ---------------------------------------------------------------------- .../ambari_agent/CustomServiceOrchestrator.py | 2 + .../main/python/ambari_agent/PythonExecutor.py | 12 +----- .../libraries/functions/__init__.py | 1 + .../functions/log_process_information.py | 40 ++++++++++++++++++++ 4 files changed, 45 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/681adc09/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py ---------------------------------------------------------------------- diff --git a/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py b/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py index fd8df01..ee34685 100644 --- a/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py +++ b/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py @@ -29,6 +29,7 @@ from FileCache import FileCache from AgentException import AgentException from PythonExecutor import PythonExecutor from PythonReflectiveExecutor import PythonReflectiveExecutor +from resource_management.libraries.functions.log_process_information import log_process_information from resource_management.core.utils import PasswordString import subprocess import Constants @@ -122,6 +123,7 @@ class CustomServiceOrchestrator(): logger.info("Canceling command with taskId = {tid}, " \ "reason - {reason} . Killing process {pid}" .format(tid=str(task_id), reason=reason, pid=pid)) + log_process_information(logger) shell.kill_process_with_children(pid) else: logger.warn("Unable to find process associated with taskId = %s" % task_id) http://git-wip-us.apache.org/repos/asf/ambari/blob/681adc09/ambari-agent/src/main/python/ambari_agent/PythonExecutor.py ---------------------------------------------------------------------- diff --git a/ambari-agent/src/main/python/ambari_agent/PythonExecutor.py b/ambari-agent/src/main/python/ambari_agent/PythonExecutor.py index 5a896ff..ea6f895 100644 --- a/ambari-agent/src/main/python/ambari_agent/PythonExecutor.py +++ b/ambari-agent/src/main/python/ambari_agent/PythonExecutor.py @@ -27,6 +27,7 @@ import platform from threading import Thread import time from BackgroundCommandExecutionHandle import BackgroundCommandExecutionHandle +from resource_management.libraries.functions.log_process_information import log_process_information from ambari_commons.os_check import OSConst, OSCheck from Grep import Grep import sys @@ -127,16 +128,7 @@ class PythonExecutor(object): Log some useful information after task failure. """ logger.info("Command " + pprint.pformat(pythonCommand) + " failed with exitcode=" + str(result['exitcode'])) - if OSCheck.is_windows_family(): - cmd_list = ["WMIC path win32_process get Caption,Processid,Commandline", "netstat -an"] - else: - cmd_list = ["export COLUMNS=9999 ; ps faux", "netstat -tulpn"] - - shell_runner = shellRunner() - - for cmd in cmd_list: - ret = shell_runner.run(cmd) - logger.info("Command '{0}' returned {1}. {2}{3}".format(cmd, ret["exitCode"], ret["error"], ret["output"])) + log_process_information(logger) def prepare_process_result(self, returncode, tmpoutfile, tmperrfile, tmpstructedoutfile, timeout=None): out, error, structured_out = self.read_result_from_files(tmpoutfile, tmperrfile, tmpstructedoutfile) http://git-wip-us.apache.org/repos/asf/ambari/blob/681adc09/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py ---------------------------------------------------------------------- diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py b/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py index f0c2e13..f144b2d 100644 --- a/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py +++ b/ambari-common/src/main/python/resource_management/libraries/functions/__init__.py @@ -45,6 +45,7 @@ from resource_management.libraries.functions.curl_krb_request import * from resource_management.libraries.functions.get_bare_principal import * from resource_management.libraries.functions.get_path_from_url import * from resource_management.libraries.functions.show_logs import * +from resource_management.libraries.functions.log_process_information import * IS_WINDOWS = platform.system() == "Windows" http://git-wip-us.apache.org/repos/asf/ambari/blob/681adc09/ambari-common/src/main/python/resource_management/libraries/functions/log_process_information.py ---------------------------------------------------------------------- diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/log_process_information.py b/ambari-common/src/main/python/resource_management/libraries/functions/log_process_information.py new file mode 100644 index 0000000..dff0474 --- /dev/null +++ b/ambari-common/src/main/python/resource_management/libraries/functions/log_process_information.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python +""" +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Ambari Agent + +""" +from ambari_commons.shell import shellRunner +from ambari_commons.os_check import OSCheck + +__all__ = ["log_process_information"] + +def log_process_information(logger): + """ + Check if certain configuration sent from the server has been received. + """ + if OSCheck.is_windows_family(): + cmd_list = ["WMIC path win32_process get Caption,Processid,Commandline", "netstat -an"] + else: + cmd_list = ["export COLUMNS=9999 ; ps faux", "netstat -tulpn", "ps auxf"] + + shell_runner = shellRunner() + + for cmd in cmd_list: + ret = shell_runner.run(cmd) + logger.info("Command '{0}' returned {1}. {2}{3}".format(cmd, ret["exitCode"], ret["error"], ret["output"]))
