You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2016/02/02 15:20:04 UTC
ambari git commit: AMBARI-14876. Ambari Agent Creating 100,
000 Empty Status Command Files (aonishuk)
Repository: ambari
Updated Branches:
refs/heads/trunk 8ba3d0beb -> 9cc01b45e
AMBARI-14876. Ambari Agent Creating 100,000 Empty Status Command Files (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9cc01b45
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9cc01b45
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9cc01b45
Branch: refs/heads/trunk
Commit: 9cc01b45ec9d534c73d10c2b0d1e4c7639883d69
Parents: 8ba3d0b
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Tue Feb 2 16:19:57 2016 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Tue Feb 2 16:19:57 2016 +0200
----------------------------------------------------------------------
.../python/ambari_agent/CustomServiceOrchestrator.py | 11 ++++++++---
.../src/main/python/ambari_agent/PythonExecutor.py | 14 ++++++++------
.../python/ambari_agent/PythonReflectiveExecutor.py | 5 +++--
3 files changed, 19 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/9cc01b45/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 6c1a161..1bc045c 100644
--- a/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
+++ b/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
@@ -56,8 +56,11 @@ class CustomServiceOrchestrator():
IPV4_ADDRESSES_KEY = "all_ipv4_ips"
AMBARI_SERVER_HOST = "ambari_server_host"
- DONT_DEBUG_FAILURES_FOR_COMMANDS = [COMMAND_NAME_SECURITY_STATUS, COMMAND_NAME_STATUS]
- REFLECTIVELY_RUN_COMMANDS = [COMMAND_NAME_SECURITY_STATUS, COMMAND_NAME_STATUS] # -- commands which run a lot and often (this increases their speed)
+
+ FREQUENT_COMMANDS = [COMMAND_NAME_SECURITY_STATUS, COMMAND_NAME_STATUS]
+ DONT_DEBUG_FAILURES_FOR_COMMANDS = FREQUENT_COMMANDS
+ REFLECTIVELY_RUN_COMMANDS = FREQUENT_COMMANDS # -- commands which run a lot and often (this increases their speed)
+ DONT_BACKUP_LOGS_FOR_COMMANDS = FREQUENT_COMMANDS
def __init__(self, config, controller):
self.config = config
@@ -185,13 +188,15 @@ class CustomServiceOrchestrator():
raise AgentException("Background commands are supported without hooks only")
python_executor = self.get_py_executor(forced_command_name)
+ backup_log_files = not command_name in self.DONT_BACKUP_LOGS_FOR_COMMANDS
for py_file, current_base_dir in filtered_py_file_list:
log_info_on_failure = not command_name in self.DONT_DEBUG_FAILURES_FOR_COMMANDS
script_params = [command_name, json_path, current_base_dir, tmpstrucoutfile, logger_level, self.exec_tmp_dir]
ret = python_executor.run_file(py_file, script_params,
tmpoutfile, tmperrfile, timeout,
tmpstrucoutfile, self.map_task_to_process,
- task_id, override_output_files, handle = handle, log_info_on_failure=log_info_on_failure)
+ task_id, override_output_files, backup_log_files = backup_log_files,
+ handle = handle, log_info_on_failure=log_info_on_failure)
# Next run_file() invocations should always append to current output
override_output_files = False
if ret['exitcode'] != 0:
http://git-wip-us.apache.org/repos/asf/ambari/blob/9cc01b45/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 352974f..0d431bc 100644
--- a/ambari-agent/src/main/python/ambari_agent/PythonExecutor.py
+++ b/ambari-agent/src/main/python/ambari_agent/PythonExecutor.py
@@ -53,11 +53,12 @@ class PythonExecutor(object):
pass
- def open_subprocess_files(self, tmpoutfile, tmperrfile, override_output_files):
- if override_output_files: # Recreate files, existing files are backed up
- self.back_up_log_file_if_exists(tmpoutfile)
+ def open_subprocess_files(self, tmpoutfile, tmperrfile, override_output_files, backup_log_files = True):
+ if override_output_files: # Recreate files, existing files are backed up if backup_log_files is True
+ if backup_log_files:
+ self.back_up_log_file_if_exists(tmpoutfile)
+ self.back_up_log_file_if_exists(tmperrfile)
tmpout = open(tmpoutfile, 'w')
- self.back_up_log_file_if_exists(tmperrfile)
tmperr = open(tmperrfile, 'w')
else: # Append to files
tmpout = open(tmpoutfile, 'a')
@@ -78,7 +79,8 @@ class PythonExecutor(object):
def run_file(self, script, script_params, tmpoutfile, tmperrfile,
timeout, tmpstructedoutfile, callback, task_id,
- override_output_files = True, handle = None, log_info_on_failure=True):
+ override_output_files = True, backup_log_files = True, handle = None,
+ log_info_on_failure = True):
"""
Executes the specified python file in a separate subprocess.
Method returns only when the subprocess is finished.
@@ -94,7 +96,7 @@ class PythonExecutor(object):
logger.debug("Running command " + pprint.pformat(pythonCommand))
if handle is None:
- tmpout, tmperr = self.open_subprocess_files(tmpoutfile, tmperrfile, override_output_files)
+ tmpout, tmperr = self.open_subprocess_files(tmpoutfile, tmperrfile, override_output_files, backup_log_files)
process = self.launch_python_subprocess(pythonCommand, tmpout, tmperr)
# map task_id to pid
http://git-wip-us.apache.org/repos/asf/ambari/blob/9cc01b45/ambari-agent/src/main/python/ambari_agent/PythonReflectiveExecutor.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/PythonReflectiveExecutor.py b/ambari-agent/src/main/python/ambari_agent/PythonReflectiveExecutor.py
index 4a7ed1c..2c42891 100644
--- a/ambari-agent/src/main/python/ambari_agent/PythonReflectiveExecutor.py
+++ b/ambari-agent/src/main/python/ambari_agent/PythonReflectiveExecutor.py
@@ -42,12 +42,13 @@ class PythonReflectiveExecutor(PythonExecutor):
def run_file(self, script, script_params, tmpoutfile, tmperrfile,
timeout, tmpstructedoutfile, callback, task_id,
- override_output_files = True, handle = None, log_info_on_failure=True):
+ override_output_files = True, backup_log_files = True,
+ handle = None, log_info_on_failure=True):
pythonCommand = self.python_command(script, script_params)
logger.debug("Running command reflectively " + pprint.pformat(pythonCommand))
script_dir = os.path.dirname(script)
- self.open_subprocess_files(tmpoutfile, tmperrfile, override_output_files)
+ self.open_subprocess_files(tmpoutfile, tmperrfile, override_output_files, backup_log_files)
returncode = 1
try: