aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject aurora git commit: Populating and validating task config in getJobUpdateDiff RPC.
Date Wed, 06 Jan 2016 17:39:28 GMT
Repository: aurora
Updated Branches:
  refs/heads/master b9d9ee3cc -> 395bd7dd9


Populating and validating task config in getJobUpdateDiff RPC.

Bugs closed: AURORA-1571

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


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

Branch: refs/heads/master
Commit: 395bd7dd9d5753784fc824742dcefbc3ab8fecb2
Parents: b9d9ee3
Author: Maxim Khutornenko <maxim@apache.org>
Authored: Wed Jan 6 09:39:15 2016 -0800
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Wed Jan 6 09:39:15 2016 -0800

----------------------------------------------------------------------
 .../aurora/scheduler/thrift/ReadOnlySchedulerImpl.java  | 12 +++++++++++-
 .../scheduler/thrift/ReadOnlySchedulerImplTest.java     |  9 +++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/395bd7dd/src/main/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImpl.java b/src/main/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImpl.java
index 90cddd0..d326d24 100644
--- a/src/main/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImpl.java
+++ b/src/main/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImpl.java
@@ -103,8 +103,10 @@ import org.apache.thrift.TException;
 
 import static java.util.Objects.requireNonNull;
 
+import static org.apache.aurora.gen.ResponseCode.INVALID_REQUEST;
 import static org.apache.aurora.scheduler.base.Numbers.convertRanges;
 import static org.apache.aurora.scheduler.base.Numbers.toRanges;
+import static org.apache.aurora.scheduler.thrift.Responses.error;
 import static org.apache.aurora.scheduler.thrift.Responses.invalidRequest;
 import static org.apache.aurora.scheduler.thrift.Responses.ok;
 
@@ -324,7 +326,15 @@ class ReadOnlySchedulerImpl implements ReadOnlyScheduler.Iface {
 
   @Override
   public Response getJobUpdateDiff(JobUpdateRequest mutableRequest) {
-    IJobUpdateRequest request = IJobUpdateRequest.build(requireNonNull(mutableRequest));
+    IJobUpdateRequest request;
+    try {
+      request = IJobUpdateRequest.build(new JobUpdateRequest(mutableRequest).setTaskConfig(
+          configurationManager.validateAndPopulate(
+              ITaskConfig.build(mutableRequest.getTaskConfig())).newBuilder()));
+    } catch (TaskDescriptionException e) {
+      return error(INVALID_REQUEST, e);
+    }
+
     IJobKey job = request.getTaskConfig().getJob();
 
     return storage.read(storeProvider -> {

http://git-wip-us.apache.org/repos/asf/aurora/blob/395bd7dd/src/test/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImplTest.java
b/src/test/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImplTest.java
index b785d8b..0428c77 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/ReadOnlySchedulerImplTest.java
@@ -852,6 +852,15 @@ public class ReadOnlySchedulerImplTest extends EasyMockTest {
     assertEquals(expected, thrift.getJobUpdateDiff(request));
   }
 
+  @Test
+  public void testGetJobUpdateDiffInvalidConfig() throws Exception {
+    control.replay();
+
+    JobUpdateRequest request =
+        new JobUpdateRequest().setTaskConfig(defaultTask(false).setNumCpus(-1));
+    assertResponse(INVALID_REQUEST, thrift.getJobUpdateDiff(request));
+  }
+
   private static void makeTasks(
       int start,
       int end,


Mime
View raw message