You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by ke...@apache.org on 2014/10/08 19:46:15 UTC

git commit: Reject new GC tasks when shutting down

Repository: incubator-aurora
Updated Branches:
  refs/heads/master 74ee724c6 -> 0e63ed232


Reject new GC tasks when shutting down

Testing Done:
./pants src/test/python/apache/aurora/executor:gc_executor

Bugs closed: AURORA-807

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


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

Branch: refs/heads/master
Commit: 0e63ed2322345c14ffbd75f9e2846903650387e0
Parents: 74ee724
Author: Kevin Sweeney <ke...@apache.org>
Authored: Wed Oct 8 10:45:38 2014 -0700
Committer: Kevin Sweeney <ke...@apache.org>
Committed: Wed Oct 8 10:45:38 2014 -0700

----------------------------------------------------------------------
 src/main/python/apache/aurora/executor/gc_executor.py    |  7 ++++++-
 .../python/apache/aurora/executor/test_gc_executor.py    | 11 +++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/0e63ed23/src/main/python/apache/aurora/executor/gc_executor.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/executor/gc_executor.py b/src/main/python/apache/aurora/executor/gc_executor.py
index 80ce6dc..788671e 100644
--- a/src/main/python/apache/aurora/executor/gc_executor.py
+++ b/src/main/python/apache/aurora/executor/gc_executor.py
@@ -493,7 +493,12 @@ class ThermosGCExecutor(ExecutorBase, ExceptionalThread, Observable):
       self._slave_id = task.slave_id.value
     task_id = task.task_id.value
     self.log('launchTask() got task_id: %s' % task_id)
-    if task_id == self._task_id:
+    if self._stop_event.is_set():
+      self.log('=> Executor is shutting down - ignoring task %s' % task_id)
+      self.send_update(
+          self._driver, task_id, mesos_pb2.TASK_FAILED, 'GC Executor is shutting down.')
+      return
+    elif task_id == self._task_id:
       self.log('=> GC with task_id %s currently running - ignoring' % task_id)
       return
     elif task_id in self._gc_task_queue:

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/0e63ed23/src/test/python/apache/aurora/executor/test_gc_executor.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/executor/test_gc_executor.py b/src/test/python/apache/aurora/executor/test_gc_executor.py
index d90dc68..1905fe3 100644
--- a/src/test/python/apache/aurora/executor/test_gc_executor.py
+++ b/src/test/python/apache/aurora/executor/test_gc_executor.py
@@ -489,6 +489,17 @@ def test_gc_shutdown_queued():
   assert proxy_driver.updates[-1][1] == TASK2_ID
 
 
+def test_ignores_launch_task_when_shutting_down():
+  """Newly launched tasks should be rejected if shutdown was already called."""
+  TASK_ID = "task"
+  proxy_driver = ProxyDriver()
+  with temporary_dir() as td:
+    executor = build_blocking_gc_executor(td, proxy_driver)
+    executor.shutdown(proxy_driver)
+    executor.launchTask(proxy_driver, serialize_art(AdjustRetainedTasks(), task_id=TASK_ID))
+    assert (mesos_pb2.TASK_FAILED, TASK_ID) == proxy_driver.updates[-1]
+
+
 def make_gc_executor_with_timeouts(
     maximum_executor_wait=Amount(15, Time.MINUTES),
     maximum_executor_lifetime=Amount(1, Time.DAYS)):