aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wfar...@apache.org
Subject incubator-aurora git commit: Remove stracktrace redirection.
Date Tue, 11 Nov 2014 01:11:02 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 01958b1df -> 5b3b75173


Remove stracktrace redirection.

Bugs closed: AURORA-896

Reviewed at https://reviews.apache.org/r/27710/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/5b3b7517
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/5b3b7517
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/5b3b7517

Branch: refs/heads/master
Commit: 5b3b75173993fb6c84e8613f02867dcc3aa68e2a
Parents: 01958b1
Author: Zameer Manji <zmanji@twopensource.com>
Authored: Mon Nov 10 17:10:41 2014 -0800
Committer: Bill Farner <wfarner@apache.org>
Committed: Mon Nov 10 17:10:41 2014 -0800

----------------------------------------------------------------------
 .../python/apache/aurora/client/cli/__init__.py | 39 +-------------------
 .../aurora/client/cli/standalone_client.py      | 26 -------------
 .../apache/aurora/client/cli/test_create.py     | 36 ------------------
 3 files changed, 2 insertions(+), 99 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/5b3b7517/src/main/python/apache/aurora/client/cli/__init__.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/cli/__init__.py b/src/main/python/apache/aurora/client/cli/__init__.py
index 67cf403..83416e6 100644
--- a/src/main/python/apache/aurora/client/cli/__init__.py
+++ b/src/main/python/apache/aurora/client/cli/__init__.py
@@ -33,10 +33,7 @@ from __future__ import print_function
 import argparse
 import getpass
 import logging
-import os
-import os.path
 import sys
-import time
 import traceback
 from abc import abstractmethod
 from uuid import uuid1
@@ -108,16 +105,6 @@ class Context(object):
       self.msg = msg
       self.code = code
 
-  ERROR_LOG_DIR = None
-
-  @staticmethod
-  def set_error_log_dir(dir):
-    Context.ERROR_LOG_DIR = dir  # noqa
-
-  @staticmethod
-  def get_error_log_dir():
-    return Context.ERROR_LOG_DIR # noqa
-
   def __init__(self):
     self.options = None
     self.logging_level = None
@@ -418,30 +405,10 @@ class CommandLine(object):
       self.print_err("Error executing command: %s" % c.msg)
       return c.code
     except Exception:
-      exc_type, exc_value, exc_traceback = sys.exc_info()
-      self.dump_error_log(args, exc_type, exc_value, exc_traceback)
+      print("Fatal error running command:", file=sys.stderr)
+      print(traceback.format_exc(), file=sys.stderr)
       return EXIT_UNKNOWN_ERROR
 
-  def dump_error_log(self, cmd_args, exc_type, exc_value, exc_traceback):
-    """Create an error log file in the directly where a command was executed,
-    and print detailed information about the error into the file.
-    :param cmd_args: the command-line arguments passed to the command that resulted in an
error.
-    :param exc_type: the exc_type value for the error returnen by sys.exc_info()
-    :param exc_value: the exc_value value for the error returnen by sys.exc_info()
-    :param exc_traceback: the exc_traceback value for the error returnen by sys.exc_info()
-    """
-    now = str(int(time.time()))
-    dir = os.path.expanduser(Context.get_error_log_dir())
-    if not os.path.isdir(dir):
-      os.makedirs(dir)
-    path = os.path.join(dir, "%s-%s.error-log" % (self.name, now))
-    print("Fatal error running command; traceback can be found in %s" % path,
-        file=sys.stderr)
-
-    with open(path, "w") as out:
-      print("ERROR LOG: command arguments = %s" % cmd_args, file=out)
-      traceback.print_exception(exc_type, exc_value, exc_traceback, file=out)
-
   def execute(self, args):
     try:
       return self._execute(args)
@@ -450,8 +417,6 @@ class CommandLine(object):
       return EXIT_INTERRUPTED
     except Exception as e:
       print_aurora_log(logging.ERROR, "Unknown error: %s" % e)
-      exc_type, exc_value, exc_traceback = sys.exc_info()
-      self.dump_error_log(args, exc_type, exc_value, exc_traceback)
       return EXIT_UNKNOWN_ERROR
 
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/5b3b7517/src/main/python/apache/aurora/client/cli/standalone_client.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/cli/standalone_client.py b/src/main/python/apache/aurora/client/cli/standalone_client.py
index a4b71eb..93120a1 100644
--- a/src/main/python/apache/aurora/client/cli/standalone_client.py
+++ b/src/main/python/apache/aurora/client/cli/standalone_client.py
@@ -21,31 +21,6 @@ from apache.aurora.client.cli.logsetup import setup_default_log_handlers
 from apache.aurora.client.cli.options import CommandOption
 
 
-class AuroraErrorHandlingPlugin(ConfigurationPlugin):
-  """Plugin for managing error logs for internal system errors.
-  When an unknown error occurs, the command-line supresses the stack dump on standard out/standard
-  error and instead dumps the detailed information including the stack trace into a log
-  file. This plugin allows the location where the error log will be written to be defined
by
-  the user.
-  """
-
-  def get_options(self):
-    return [
-        CommandOption("--error-log-dir", default="~/.aurora/errors",
-            help="Directory location where error files containing stack traces "
-            "should be written. If the directory doesn't exist, it will be "
-            "created")]
-
-  def before_dispatch(self, raw_args):
-    return raw_args
-
-  def before_execution(self, context):
-    context.set_error_log_dir(context.options.error_log_dir)
-
-  def after_execution(self, context, result_code):
-    pass
-
-
 class AuroraLogConfigurationPlugin(ConfigurationPlugin):
   """Plugin for configuring log level settings for the aurora client."""
 
@@ -100,7 +75,6 @@ class AuroraCommandLine(CommandLine):
   def __init__(self):
     super(AuroraCommandLine, self).__init__()
     self.register_plugin(AuroraLogConfigurationPlugin())
-    self.register_plugin(AuroraErrorHandlingPlugin())
 
   @property
   def name(self):

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/5b3b7517/src/test/python/apache/aurora/client/cli/test_create.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/test_create.py b/src/test/python/apache/aurora/client/cli/test_create.py
index 1dec54c..968c997 100644
--- a/src/test/python/apache/aurora/client/cli/test_create.py
+++ b/src/test/python/apache/aurora/client/cli/test_create.py
@@ -13,8 +13,6 @@
 #
 
 import contextlib
-import os
-import shutil
 
 from mock import create_autospec, patch
 from twitter.common.contextutil import temporary_file
@@ -159,37 +157,6 @@ class TestClientCreateCommand(AuroraClientCommandTest):
       self.assert_scheduler_called(api, mock_query, 2)
       assert mock_context.showed_urls == ["http://something_or_other/scheduler/bozo/test/hello"]
 
-  def test_create_job_fail_and_write_log(self):
-    """Check that when an unknown error occurs during command execution,
-    the command-line framework catches it, and writes out an error log file
-    containing the details of the error, including the command-line arguments
-    passed to aurora to execute the command, and the stack trace of the error.
-    """
-    mock_context = FakeAuroraCommandContext()
-    with contextlib.nested(
-        patch('time.time', return_value=23),
-        patch('apache.aurora.client.cli.jobs.Job.create_context', return_value=mock_context)):
-      api = mock_context.get_api('west')
-      api.create_job.side_effect = UnknownException()
-
-      with temporary_file() as fp:
-        fp.write(self.get_valid_config())
-        fp.flush()
-        cmd = AuroraCommandLine()
-        result = cmd.execute(['job', 'create', '--wait-until=RUNNING',
-           '--error-log-dir=./logged-errors', 'west/bozo/test/hello',
-            fp.name])
-        assert result == EXIT_UNKNOWN_ERROR
-        with open("./logged-errors/aurora-23.error-log", "r") as logfile:
-          error_log = logfile.read()
-          assert error_log.startswith("ERROR LOG: command arguments = %s" %
-              ['job', 'create', '--wait-until=RUNNING', '--error-log-dir=./logged-errors',
-               'west/bozo/test/hello',
-              fp.name])
-          assert "Traceback" in error_log
-        if os.path.exists("./logged-errors"):
-          shutil.rmtree("./logged-errors")
-
   def test_create_job_delayed(self):
     """Run a test of the "create" command against a mocked-out API:
     this time, make the monitor check status several times before successful completion.
@@ -283,12 +250,9 @@ class TestClientCreateCommand(AuroraClientCommandTest):
         fp.flush()
         cmd = AuroraCommandLine()
         result = cmd.execute(['job', 'create', '--wait-until=RUNNING', 'west/bozo/test/hello',
-            '--error-log-dir=./error-logs',
             fp.name])
         assert result == EXIT_UNKNOWN_ERROR
         assert api.create_job.call_count == 0
-        if os.path.exists("./error-logs"):
-          shutil.rmtree("./error-logs")
 
   def test_simple_successful_create_job_output(self):
     """Run a test of the "create" command against a mocked-out API:


Mime
View raw message