Explorar el Código

AMBARI-16154. RU/EU fails due to changes in script.py arguments (aonishuk)

Andrew Onishuk hace 9 años
padre
commit
97b44238e5

+ 5 - 1
ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py

@@ -193,7 +193,11 @@ class CustomServiceOrchestrator():
       
       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, str(log_out_files)]
+        script_params = [command_name, json_path, current_base_dir, tmpstrucoutfile, logger_level, self.exec_tmp_dir]
+        
+        if log_out_files:
+          script_params.append("-o")
+        
         ret = python_executor.run_file(py_file, script_params,
                                tmpoutfile, tmperrfile, timeout,
                                tmpstrucoutfile, self.map_task_to_process,

+ 11 - 5
ambari-common/src/main/python/resource_management/libraries/script/script.py

@@ -28,6 +28,7 @@ import logging
 import platform
 import inspect
 import tarfile
+from optparse import OptionParser
 import resource_management
 from ambari_commons import OSCheck, OSConst
 from ambari_commons.constants import UPGRADE_TYPE_NON_ROLLING, UPGRADE_TYPE_ROLLING
@@ -63,7 +64,7 @@ if OSCheck.is_windows_family():
 else:
   from resource_management.libraries.functions.tar_archive import archive_dir
 
-USAGE = """Usage: {0} <COMMAND> <JSON_CONFIG> <BASEDIR> <STROUTPUT> <LOGGING_LEVEL> <TMP_DIR> <LOG_OUT_FILES>
+USAGE = """Usage: {0} <COMMAND> <JSON_CONFIG> <BASEDIR> <STROUTPUT> <LOGGING_LEVEL> <TMP_DIR>
 
 <COMMAND> command type (INSTALL/CONFIGURE/START/STOP/SERVICE_CHECK...)
 <JSON_CONFIG> path to command json file. Ex: /var/lib/ambari-agent/data/command-2.json
@@ -71,7 +72,6 @@ USAGE = """Usage: {0} <COMMAND> <JSON_CONFIG> <BASEDIR> <STROUTPUT> <LOGGING_LEV
 <STROUTPUT> path to file with structured command output (file will be created). Ex:/tmp/my.txt
 <LOGGING_LEVEL> log level for stdout. Ex:DEBUG,INFO
 <TMP_DIR> temporary directory for executable scripts. Ex: /var/lib/ambari-agent/tmp
-<LOG_OUT_FILES> before start is done, should the service *.out files content be logged. Ex: false 
 """
 
 _PASSWORD_MAP = {"/configurations/cluster-env/hadoop.user.name":"/configurations/cluster-env/hadoop.user.password"}
@@ -198,9 +198,16 @@ class Script(object):
     Sets up logging;
     Parses command parameters and executes method relevant to command type
     """
+    parser = OptionParser()
+    parser.add_option("-o", "--out-files-logging", dest="log_out_files", action="store_true",
+                      help="use this option to enable outputting *.out files of the service pre-start")
+    (self.options, args) = parser.parse_args()
+    
+    self.log_out_files = self.options.log_out_files
+    
     # parse arguments
-    if len(sys.argv) < 8:
-     print "Script expects at least 7 arguments"
+    if len(args) < 6:
+     print "Script expects at least 6 arguments"
      print USAGE.format(os.path.basename(sys.argv[0])) # print to stdout
      sys.exit(1)
      
@@ -211,7 +218,6 @@ class Script(object):
     self.load_structured_out()
     self.logging_level = sys.argv[5]
     Script.tmp_dir = sys.argv[6]
-    self.log_out_files = sys.argv[7].lower() == "true"
     
     logging_level_str = logging._levelNames[self.logging_level]
     Logger.initialize_logger(__name__, logging_level=logging_level_str)