diff options
author | mbligh <mbligh@592f7852-d20e-0410-864c-8624ca9c26a4> | 2009-06-08 16:33:34 +0000 |
---|---|---|
committer | mbligh <mbligh@592f7852-d20e-0410-864c-8624ca9c26a4> | 2009-06-08 16:33:34 +0000 |
commit | 03b267a1cdc0e4611c866e72d9504bee83ae6a8b (patch) | |
tree | 361fee82bca8a2ba1fad8595180ba7cdcc9adbfe | |
parent | 5bf15d5c1ec5fd7ab8b0c297377ccbda3a5dab62 (diff) |
Add in some try-except handling to the server profiler launcher so that
if it fails for some reason we try to get the client.log from the
profiler. Otherwise there's no good way to determine why the profiler
failed, since we run it in temp dirs that get cleaned up by the end
of the job (and so nothing is available for a post-mortem).
Risk: Medium
Visibility: Adds some log collection during server profiler failures.
Signed-off-by: John Admanski <jadmanski@google.com>
git-svn-id: svn://test.kernel.org/autotest/trunk@3204 592f7852-d20e-0410-864c-8624ca9c26a4
-rw-r--r-- | server/profiler.py | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/server/profiler.py b/server/profiler.py index c7279e1b..0f1da51d 100644 --- a/server/profiler.py +++ b/server/profiler.py @@ -1,4 +1,4 @@ -import os, itertools, shutil, tempfile +import os, itertools, shutil, tempfile, logging import common from autotest_lib.client.common_lib import utils, error @@ -56,6 +56,12 @@ def encode_args(profiler, args, dargs): return ", ".join(parts) +def get_profiler_log_path(autodir): + """Given the directory of a profiler client, find the client log path.""" + return os.path.join(PROFILER_TMPDIR, autodir, "results", "default", + "client.log") + + def get_profiler_results_dir(autodir): """ Given the directory of the autotest client used to run a profiler, return the remote path where profiler results will be stored.""" @@ -146,6 +152,21 @@ class profiler_proxy(object): return {} + def _get_failure_logs(self, autodir, test, host): + """Collect the client logs from a profiler run and put them in a + file named failure-*.log.""" + try: + fd, path = tempfile.mkstemp(suffix=".log", prefix="failure", + dir=os.path.join(test.profdir, + host.hostname)) + os.close(fd) + host.get_file(get_profiler_log_path(autodir), path) + except (error.AutotestError, error.AutoservError): + logging.exception("Profiler failure log collection failed") + # swallow the exception so that we don't override an existing + # exception being thrown + + def start(self, test, host=None): self._install() encoded_args = encode_args(self.name, self.args, self.dargs) @@ -154,16 +175,24 @@ class profiler_proxy(object): fifo_pattern = os.path.join(autodir, "profiler.*") host.run("rm -f %s" % fifo_pattern) host.run("mkfifo %s" % os.path.join(autodir, "profiler.ready")) - at.run(control_script, background=True) - self._wait_on_client(host, autodir, "ready") - self._signal_client(host, autodir, "start") + try: + at.run(control_script, background=True) + self._wait_on_client(host, autodir, "ready") + self._signal_client(host, autodir, "start") + except: + self._get_failure_logs(autodir, test, host) + raise self.current_test = test def stop(self, test, host=None): assert self.current_test == test for host, (at, autodir) in self._get_hosts(host).iteritems(): - self._signal_client(host, autodir, "stop") + try: + self._signal_client(host, autodir, "stop") + except: + self._get_failure_logs(autodir, test, host) + raise def report(self, test, host=None, wait_on_client=True): @@ -173,7 +202,11 @@ class profiler_proxy(object): # signal to all the clients that they should report if wait_on_client: for host, (at, autodir) in self._get_hosts(host).iteritems(): - self._signal_client(host, autodir, "report") + try: + self._signal_client(host, autodir, "report") + except: + self._get_failure_logs(autodir, test, host) + raise # pull back all the results for host, (at, autodir) in self._get_hosts(host).iteritems(): |