You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by wi...@apache.org on 2014/03/20 01:02:38 UTC

git commit: Don't forget to register status checker observables.

Repository: incubator-aurora
Updated Branches:
  refs/heads/master d83729896 -> a73ee1394


Don't forget to register status checker observables.

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


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

Branch: refs/heads/master
Commit: a73ee1394f938da730be8c7c682f3555a1f116b4
Parents: d837298
Author: Brian Wickman <wi...@apache.org>
Authored: Wed Mar 19 17:02:33 2014 -0700
Committer: Brian Wickman <wi...@apache.org>
Committed: Wed Mar 19 17:02:33 2014 -0700

----------------------------------------------------------------------
 src/main/python/apache/aurora/executor/aurora_executor.py      | 6 ++++--
 src/main/python/apache/aurora/executor/common/kill_manager.py  | 3 +++
 .../python/apache/aurora/executor/common/status_checker.py     | 4 ++++
 .../python/apache/aurora/executor/test_thermos_executor.py     | 6 +++++-
 4 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/a73ee139/src/main/python/apache/aurora/executor/aurora_executor.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/executor/aurora_executor.py b/src/main/python/apache/aurora/executor/aurora_executor.py
index 28e5054..9dff12b 100644
--- a/src/main/python/apache/aurora/executor/aurora_executor.py
+++ b/src/main/python/apache/aurora/executor/aurora_executor.py
@@ -80,6 +80,7 @@ class AuroraExecutor(ExecutorBase, Observable):
     self.runner_started = threading.Event()
     self.sandbox_initialized = threading.Event()
     self.sandbox_created = threading.Event()
+    self.status_manager_started = threading.Event()
     self.terminated = threading.Event()
     self.launched = threading.Event()
 
@@ -160,14 +161,14 @@ class AuroraExecutor(ExecutorBase, Observable):
 
   def _start_status_manager(self, driver, assigned_task):
     status_checkers = [self._kill_manager]
-    self.metrics.register_observable('kill_manager', self._kill_manager)
+    self.metrics.register_observable(self._kill_manager.name(), self._kill_manager)
 
     for status_provider in self._status_providers:
       status_checker = status_provider.from_assigned_task(assigned_task, self._sandbox)
       if status_checker is None:
         continue
       status_checkers.append(status_checker)
-      # self.metrics.register_observable()
+      self.metrics.register_observable(status_checker.name(), status_checker)
 
     self._chained_checker = ChainedStatusChecker(status_checkers)
     self._chained_checker.start()
@@ -177,6 +178,7 @@ class AuroraExecutor(ExecutorBase, Observable):
     self._status_manager = self._status_manager_class(
         complete_checker, self._shutdown, clock=self._clock)
     self._status_manager.start()
+    self.status_manager_started.set()
 
   def _signal_kill_manager(self, driver, task_id, reason):
     if self._task_id is None:

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/a73ee139/src/main/python/apache/aurora/executor/common/kill_manager.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/executor/common/kill_manager.py b/src/main/python/apache/aurora/executor/common/kill_manager.py
index 0d0d553..86ee4e6 100644
--- a/src/main/python/apache/aurora/executor/common/kill_manager.py
+++ b/src/main/python/apache/aurora/executor/common/kill_manager.py
@@ -30,6 +30,9 @@ class KillManager(StatusChecker):
     if self._killed:
       return StatusResult(self._reason, ExitState.KILLED)
 
+  def name(self):
+    return 'kill_manager'
+
   def kill(self, reason):
     self._reason = reason
     self._killed = True

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/a73ee139/src/main/python/apache/aurora/executor/common/status_checker.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/executor/common/status_checker.py b/src/main/python/apache/aurora/executor/common/status_checker.py
index f94042c..2d4fffc 100644
--- a/src/main/python/apache/aurora/executor/common/status_checker.py
+++ b/src/main/python/apache/aurora/executor/common/status_checker.py
@@ -74,6 +74,10 @@ class StatusChecker(Observable, Interface):
   def status(self):
     """Return None under normal operations.  Return StatusResult to indicate status proposal."""
 
+  def name(self):
+    """Return the name of the status checker.  By default it is the class name.  Subclassable."""
+    return self.__class__.__name__
+
   def start(self):
     """Invoked once the task has been started."""
     self.metrics.register(NamedGauge('enabled', 1))

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/a73ee139/src/test/python/apache/aurora/executor/test_thermos_executor.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/executor/test_thermos_executor.py b/src/test/python/apache/aurora/executor/test_thermos_executor.py
index b508eab..4cd34c6 100644
--- a/src/test/python/apache/aurora/executor/test_thermos_executor.py
+++ b/src/test/python/apache/aurora/executor/test_thermos_executor.py
@@ -205,7 +205,11 @@ def make_executor(
   task_description = make_task(task, assigned_ports=ports, instanceId=0)
   te.launchTask(proxy_driver, task_description)
 
-  te.runner_started.wait()
+  te.status_manager_started.wait()
+  sampled_metrics = te.metrics.sample()
+  assert 'kill_manager.enabled' in sampled_metrics
+  for checker in te._chained_checker._status_checkers:  # hacky
+    assert ('%s.enabled' % checker.name()) in sampled_metrics
 
   while len(proxy_driver.method_calls['sendStatusUpdate']) < 2:
     time.sleep(0.1)