aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wfar...@apache.org
Subject git commit: Make job key backfilling more robust.
Date Tue, 28 Oct 2014 01:06:43 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 82dd7d197 -> 9fb2ce4c5


Make job key backfilling more robust.

Bugs closed: AURORA-897

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


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

Branch: refs/heads/master
Commit: 9fb2ce4c5d7f26d008525d1642ad4cb5629cfbe3
Parents: 82dd7d1
Author: Bill Farner <wfarner@apache.org>
Authored: Mon Oct 27 18:05:57 2014 -0700
Committer: Bill Farner <wfarner@apache.org>
Committed: Mon Oct 27 18:05:57 2014 -0700

----------------------------------------------------------------------
 .../scheduler/storage/StorageBackfill.java      |  3 +-
 .../scheduler/storage/StorageBackfillTest.java  | 54 ++++++++++++++++++--
 2 files changed, 51 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9fb2ce4c/src/main/java/org/apache/aurora/scheduler/storage/StorageBackfill.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/StorageBackfill.java b/src/main/java/org/apache/aurora/scheduler/storage/StorageBackfill.java
index 3cadbaf..97517ed 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/StorageBackfill.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/StorageBackfill.java
@@ -30,6 +30,7 @@ import org.apache.aurora.gen.ScheduleStatus;
 import org.apache.aurora.gen.ScheduledTask;
 import org.apache.aurora.gen.TaskConfig;
 import org.apache.aurora.gen.TaskEvent;
+import org.apache.aurora.scheduler.base.JobKeys;
 import org.apache.aurora.scheduler.base.Query;
 import org.apache.aurora.scheduler.base.Tasks;
 import org.apache.aurora.scheduler.configuration.ConfigurationManager;
@@ -131,7 +132,7 @@ public final class StorageBackfill {
     storeProvider.getUnsafeTaskStore().mutateTasks(Query.unscoped(), new TaskMutation() {
       @Override
       public IScheduledTask apply(final IScheduledTask task) {
-        if (!task.getAssignedTask().getTask().isSetJob()) {
+        if (!JobKeys.isValid(task.getAssignedTask().getTask().getJob())) {
           ScheduledTask builder = task.newBuilder();
           TaskConfig config = builder.getAssignedTask().getTask();
           config.setJob(new JobKey()

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/9fb2ce4c/src/test/java/org/apache/aurora/scheduler/storage/StorageBackfillTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/StorageBackfillTest.java b/src/test/java/org/apache/aurora/scheduler/storage/StorageBackfillTest.java
index cf9b0bd..32a90d5 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/StorageBackfillTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/StorageBackfillTest.java
@@ -18,9 +18,10 @@ import java.util.concurrent.atomic.AtomicInteger;
 
 import com.google.common.base.Function;
 import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
 import com.twitter.common.util.Clock;
 import com.twitter.common.util.testing.FakeClock;
 
@@ -29,6 +30,7 @@ import org.apache.aurora.gen.Constraint;
 import org.apache.aurora.gen.ExecutorConfig;
 import org.apache.aurora.gen.Identity;
 import org.apache.aurora.gen.JobConfiguration;
+import org.apache.aurora.gen.JobKey;
 import org.apache.aurora.gen.ScheduleStatus;
 import org.apache.aurora.gen.ScheduledTask;
 import org.apache.aurora.gen.TaskConfig;
@@ -134,7 +136,6 @@ public class StorageBackfillTest {
 
   @Test
   public void testShardUniquenessCorrection() throws Exception {
-
     final AtomicInteger taskId = new AtomicInteger();
 
     final TaskConfig task = defaultTask();
@@ -166,6 +167,49 @@ public class StorageBackfillTest {
     assertEquals(9, getTasksByStatus(KILLED).size());
   }
 
+  @Test
+  public void testBackfillTaskJob() throws Exception {
+    TaskConfig task = defaultTask();
+    ConfigurationManager.applyDefaultsIfUnset(task);
+    task.unsetJob();
+
+    IScheduledTask noJobKey = IScheduledTask.build(new ScheduledTask()
+        .setStatus(RUNNING)
+        .setAssignedTask(new AssignedTask()
+            .setInstanceId(0)
+            .setTaskId("nojobkey")
+            .setTask(task)));
+    IScheduledTask nullJobKeyFields = IScheduledTask.build(new ScheduledTask()
+        .setStatus(RUNNING)
+        .setAssignedTask(new AssignedTask()
+            .setInstanceId(1)
+            .setTaskId("nulled_fields")
+            .setTask(task.setJob(new JobKey()))));
+
+    final Set<IScheduledTask> backfilledTasks = ImmutableSet.of(noJobKey, nullJobKeyFields);
+    storage.write(new Storage.MutateWork.NoResult.Quiet() {
+      @Override
+      protected void execute(Storage.MutableStoreProvider storeProvider) {
+        storeProvider.getUnsafeTaskStore().saveTasks(backfilledTasks);
+      }
+    });
+
+    backfill();
+    ScheduledTask noJobKeyBackfilled = noJobKey.newBuilder();
+    noJobKeyBackfilled.getAssignedTask().getTask()
+        .setJob(new JobKey(OWNER.getRole(), ENV, JOB_NAME));
+
+    ScheduledTask nullJobKeyFieldsBackfilled = nullJobKeyFields.newBuilder();
+    nullJobKeyFieldsBackfilled.getAssignedTask().getTask()
+        .setJob(new JobKey(OWNER.getRole(), ENV, JOB_NAME));
+
+    assertEquals(
+        ImmutableSet.of(
+            IScheduledTask.build(noJobKeyBackfilled),
+            IScheduledTask.build(nullJobKeyFieldsBackfilled)),
+        Storage.Util.consistentFetchTasks(storage, Query.unscoped()));
+  }
+
   private void backfill() {
     storage.write(new Storage.MutateWork.NoResult.Quiet() {
       @Override
@@ -200,9 +244,9 @@ public class StorageBackfillTest {
         .setRamMb(ONE_GB)
         .setDiskMb(500)
         .setExecutorConfig(EXECUTOR_CONFIG)
-        .setRequestedPorts(ImmutableSet.<String>of())
-        .setConstraints(ImmutableSet.<Constraint>of())
-        .setTaskLinks(ImmutableMap.<String, String>of());
+        .setRequestedPorts(Sets.<String>newHashSet())
+        .setConstraints(Sets.<Constraint>newHashSet())
+        .setTaskLinks(Maps.<String, String>newHashMap());
   }
 
   private IScheduledTask getTask(String taskId) {


Mime
View raw message