aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject aurora git commit: Making scheduler loop continue after mismatch.
Date Thu, 13 Aug 2015 21:48:02 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 887ffd2c4 -> 76d5a49ab


Making scheduler loop continue after mismatch.

Bugs closed: AURORA-1435

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


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

Branch: refs/heads/master
Commit: 76d5a49ab9720e7fc4b2ee417f91ddb6bb45c671
Parents: 887ffd2
Author: Maxim Khutornenko <maxim@apache.org>
Authored: Thu Aug 13 14:47:37 2015 -0700
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Thu Aug 13 14:47:37 2015 -0700

----------------------------------------------------------------------
 .../aurora/scheduler/state/TaskAssigner.java    |  1 -
 .../scheduler/state/TaskAssignerImplTest.java   | 49 ++++++++++++++++++++
 2 files changed, 49 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/76d5a49a/src/main/java/org/apache/aurora/scheduler/state/TaskAssigner.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/state/TaskAssigner.java b/src/main/java/org/apache/aurora/scheduler/state/TaskAssigner.java
index 14d70df..38375db 100644
--- a/src/main/java/org/apache/aurora/scheduler/state/TaskAssigner.java
+++ b/src/main/java/org/apache/aurora/scheduler/state/TaskAssigner.java
@@ -186,7 +186,6 @@ public interface TaskAssigner {
 
           LOG.fine("Slave " + offer.getOffer().getHostname()
               + " vetoed task " + taskId + ": " + vetoes);
-          return false;
         }
       }
       return false;

http://git-wip-us.apache.org/repos/asf/aurora/blob/76d5a49a/src/test/java/org/apache/aurora/scheduler/state/TaskAssignerImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/state/TaskAssignerImplTest.java b/src/test/java/org/apache/aurora/scheduler/state/TaskAssignerImplTest.java
index 1de1d1f..99bc80a 100644
--- a/src/test/java/org/apache/aurora/scheduler/state/TaskAssignerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/state/TaskAssignerImplTest.java
@@ -274,4 +274,53 @@ public class TaskAssignerImplTest extends EasyMockTest {
         Tasks.id(TASK),
         ImmutableMap.of(SLAVE_ID, GROUP_KEY)));
   }
+
+  @Test
+  public void testAssignerDoesNotReturnOnFirstMismatch() throws Exception {
+    // Ensures scheduling loop does not terminate prematurely when the first mismatch is
identified.
+    HostOffer mismatched = new HostOffer(
+        Offer.newBuilder()
+            .setId(OfferID.newBuilder().setValue("offerId0"))
+            .setFrameworkId(FrameworkID.newBuilder().setValue("frameworkId"))
+            .setSlaveId(SlaveID.newBuilder().setValue("slaveId0"))
+            .setHostname("hostName0")
+            .addResources(Resource.newBuilder()
+                .setName("ports")
+                .setType(Type.RANGES)
+                .setRanges(
+                    Ranges.newBuilder().addRange(Range.newBuilder().setBegin(PORT).setEnd(PORT))))
+            .build(),
+        IHostAttributes.build(new HostAttributes()));
+
+    expect(offerManager.getOffers(GROUP_KEY)).andReturn(ImmutableSet.of(mismatched, OFFER));
+    expect(filter.filter(
+        new UnusedResource(ResourceSlot.from(mismatched.getOffer()), mismatched.getAttributes()),
+        new ResourceRequest(TASK.getAssignedTask().getTask(), EMPTY)))
+        .andReturn(ImmutableSet.of(Veto.constraintMismatch("constraint mismatch")));
+    offerManager.banOffer(mismatched.getOffer().getId(), GROUP_KEY);
+    expect(filter.filter(
+        new UnusedResource(ResourceSlot.from(OFFER.getOffer()), OFFER.getAttributes()),
+        new ResourceRequest(TASK.getAssignedTask().getTask(), EMPTY)))
+        .andReturn(ImmutableSet.of());
+
+    expect(stateManager.assignTask(
+        storeProvider,
+        Tasks.id(TASK),
+        OFFER.getOffer().getHostname(),
+        OFFER.getOffer().getSlaveId(),
+        ImmutableMap.of(PORT_NAME, PORT)))
+        .andReturn(TASK.getAssignedTask());
+    expect(taskFactory.createFrom(TASK.getAssignedTask(), OFFER.getOffer().getSlaveId()))
+        .andReturn(TASK_INFO);
+    offerManager.launchTask(OFFER.getOffer().getId(), TASK_INFO);
+
+    control.replay();
+
+    assertTrue(assigner.maybeAssign(
+        storeProvider,
+        new ResourceRequest(TASK.getAssignedTask().getTask(), EMPTY),
+        TaskGroupKey.from(TASK.getAssignedTask().getTask()),
+        Tasks.id(TASK),
+        ImmutableMap.of(SLAVE_ID, GROUP_KEY)));
+  }
 }


Mime
View raw message