Repository: aurora
Updated Branches:
  refs/heads/master daf5c1bb0 -> b4e66bcf2


Do not reschedule a PARTITIONED task if it was in KILLING state.

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


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

Branch: refs/heads/master
Commit: b4e66bcf27bd845842ae848fe8575fd1850c6dce
Parents: daf5c1b
Author: David McLaughlin <da...@dmclaughlin.com>
Authored: Wed Feb 14 11:18:31 2018 -0800
Committer: David McLaughlin <da...@dmclaughlin.com>
Committed: Wed Feb 14 11:18:31 2018 -0800

----------------------------------------------------------------------
 .../apache/aurora/scheduler/state/TaskStateMachine.java |  8 +++++++-
 .../aurora/scheduler/state/TaskStateMachineTest.java    | 12 ++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/b4e66bcf/src/main/java/org/apache/aurora/scheduler/state/TaskStateMachine.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/aurora/scheduler/state/TaskStateMachine.java 
b/src/main/java/org/apache/aurora/scheduler/state/TaskStateMachine.java
index f325bf4..f39016a 100644
--- a/src/main/java/org/apache/aurora/scheduler/state/TaskStateMachine.java
+++ b/src/main/java/org/apache/aurora/scheduler/state/TaskStateMachine.java
@@ -289,7 +289,13 @@ class TaskStateMachine {
                       switch (transition.getTo()) {
                         case LOST:
                           addFollowup(KILL);
-                          addFollowup(RESCHEDULE);
+                          // only reschedule if we didn't go KILLING -> 
PARTITIONED -> LOST.
+                          if (task.get()
+                              .getTaskEvents()
+                              .stream()
+                              .noneMatch(e -> 
e.getStatus().equals(ScheduleStatus.KILLING))) {
+                            addFollowup(RESCHEDULE);
+                          }
                           break;
                         case KILLING:
                         case RESTARTING:

http://git-wip-us.apache.org/repos/asf/aurora/blob/b4e66bcf/src/test/java/org/apache/aurora/scheduler/state/TaskStateMachineTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/aurora/scheduler/state/TaskStateMachineTest.java 
b/src/test/java/org/apache/aurora/scheduler/state/TaskStateMachineTest.java
index 050a46a..b6dfafa 100644
--- a/src/test/java/org/apache/aurora/scheduler/state/TaskStateMachineTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/state/TaskStateMachineTest.java
@@ -29,6 +29,7 @@ import com.google.common.collect.Sets;
 
 import org.apache.aurora.gen.ScheduleStatus;
 import org.apache.aurora.gen.ScheduledTask;
+import org.apache.aurora.gen.TaskEvent;
 import org.apache.aurora.scheduler.base.TaskTestUtil;
 import org.apache.aurora.scheduler.base.Tasks;
 import org.apache.aurora.scheduler.state.SideEffect.Action;
@@ -90,6 +91,17 @@ public class TaskStateMachineTest {
   }
 
   @Test
+  public void testPartitionedAndLostOnlyReschedulesWhenNotKilling() {
+    ScheduledTask task = makeTask(true);
+    task.addToTaskEvents(new TaskEvent().setStatus(ScheduleStatus.KILLING));
+    stateMachine = makeStateMachine(task);
+    expectUpdateStateOnTransitionTo(PENDING, ASSIGNED, STARTING, RUNNING);
+    legalTransition(KILLING, Action.SAVE_STATE, Action.KILL);
+    legalTransition(PARTITIONED, Action.SAVE_STATE, Action.TRANSITION_TO_LOST);
+    legalTransition(LOST, Action.SAVE_STATE, Action.KILL);
+  }
+
+  @Test
   public void testPostTerminalTransitionDenied() {
     for (ScheduleStatus endState : Tasks.TERMINAL_STATES) {
       stateMachine = makeStateMachine(makeTask(false));

Reply via email to