You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by ma...@apache.org on 2016/03/10 21:20:17 UTC

aurora git commit: Adding non-role-exclusive dedicated constraint support

Repository: aurora
Updated Branches:
  refs/heads/master 31a538f19 -> c5f94e05f


Adding non-role-exclusive dedicated constraint support

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


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

Branch: refs/heads/master
Commit: c5f94e05f61778ec11fcce5b1f07dd69c5f843d1
Parents: 31a538f
Author: Maxim Khutornenko <ma...@apache.org>
Authored: Thu Mar 10 12:19:58 2016 -0800
Committer: Maxim Khutornenko <ma...@apache.org>
Committed: Thu Mar 10 12:19:58 2016 -0800

----------------------------------------------------------------------
 NEWS                                            |  3 ++
 docs/deploying-aurora-scheduler.md              | 11 +++++-
 .../configuration/ConfigurationManager.java     |  2 +-
 .../configuration/ConfigurationManagerTest.java | 36 +++++++++++++++++++-
 4 files changed, 49 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/c5f94e05/NEWS
----------------------------------------------------------------------
diff --git a/NEWS b/NEWS
index 0aa7f5e..da3e4ce 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,9 @@ New/updated:
 - Upgraded Mesos to 0.26.0
 - Added a new `aurora job add` client command to scale out an existing job.
 - Upgraded the scheduler ZooKeeper client from 3.4.6 to 3.4.8.
+- Added support for dedicated constraints not exclusive to a particular role.
+  See https://github.com/apache/aurora/blob/master/docs/deploying-aurora-scheduler.md#dedicated-attribute
+  for more details.
 
 Deprecations and removals:
 

http://git-wip-us.apache.org/repos/asf/aurora/blob/c5f94e05/docs/deploying-aurora-scheduler.md
----------------------------------------------------------------------
diff --git a/docs/deploying-aurora-scheduler.md b/docs/deploying-aurora-scheduler.md
index 10952ef..03ee360 100644
--- a/docs/deploying-aurora-scheduler.md
+++ b/docs/deploying-aurora-scheduler.md
@@ -279,7 +279,16 @@ The dedicated attribute has semantic meaning. The format is `$role(/.*)?`. When
 the scheduler requires that the `$role` component matches the `role` field in the job
 configuration, and will reject the job creation otherwise.  The remainder of the attribute is
 free-form. We've developed the idiom of formatting this attribute as `$role/$job`, but do not
-enforce this.
+enforce this. For example: a job `devcluster/www-data/prod/hello` with a dedicated constraint set as
+`www-data/web.multi` will have its tasks scheduled only on Mesos slaves configured with:
+`--attributes=dedicated:www-data/web.multi`.
+
+A wildcard (`*`) may be used for the role portion of the dedicated attribute, which will allow any
+owner to elect for a job to run on the host(s). For example: tasks from both
+`devcluster/www-data/prod/hello` and `devcluster/vagrant/test/hello` with a dedicated constraint
+formatted as `*/web.multi` will be scheduled only on Mesos slaves configured with
+`--attributes=dedicated:*/web.multi`. This may be useful when assembling a virtual cluster of
+machines sharing the same set of traits or requirements.
 
 ##### Example
 Consider the following slave command line:

http://git-wip-us.apache.org/repos/asf/aurora/blob/c5f94e05/src/main/java/org/apache/aurora/scheduler/configuration/ConfigurationManager.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/configuration/ConfigurationManager.java b/src/main/java/org/apache/aurora/scheduler/configuration/ConfigurationManager.java
index 6300e5f..e700fa3 100644
--- a/src/main/java/org/apache/aurora/scheduler/configuration/ConfigurationManager.java
+++ b/src/main/java/org/apache/aurora/scheduler/configuration/ConfigurationManager.java
@@ -224,7 +224,7 @@ public class ConfigurationManager {
       }
 
       String dedicatedRole = getRole(valueConstraint);
-      if (!config.getJob().getRole().equals(dedicatedRole)) {
+      if (!("*".equals(dedicatedRole) || config.getJob().getRole().equals(dedicatedRole))) {
         throw new TaskDescriptionException(
             "Only " + dedicatedRole + " may use hosts dedicated for that role.");
       }

http://git-wip-us.apache.org/repos/asf/aurora/blob/c5f94e05/src/test/java/org/apache/aurora/scheduler/configuration/ConfigurationManagerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/configuration/ConfigurationManagerTest.java b/src/test/java/org/apache/aurora/scheduler/configuration/ConfigurationManagerTest.java
index d2789d0..11062e3 100644
--- a/src/test/java/org/apache/aurora/scheduler/configuration/ConfigurationManagerTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/configuration/ConfigurationManagerTest.java
@@ -60,13 +60,15 @@ public class ConfigurationManagerTest {
   private static final ImmutableSet<Container._Fields> ALL_CONTAINER_TYPES =
       ImmutableSet.of(Container._Fields.DOCKER, Container._Fields.MESOS);
 
+  private static final JobKey JOB_KEY = new JobKey("owner-role", "devel", "email_stats");
   private static final JobConfiguration UNSANITIZED_JOB_CONFIGURATION = new JobConfiguration()
-      .setKey(new JobKey("owner-role", "devel", "email_stats"))
+      .setKey(JOB_KEY)
       .setCronSchedule("0 2 * * *")
       .setCronCollisionPolicy(CronCollisionPolicy.KILL_EXISTING)
       .setInstanceCount(1)
       .setTaskConfig(
           new TaskConfig()
+              .setJob(JOB_KEY)
               .setIsService(false)
               .setTaskLinks(ImmutableMap.of())
               .setExecutorConfig(new ExecutorConfig("aurora", "config"))
@@ -180,6 +182,38 @@ public class ConfigurationManagerTest {
     assertThat(params, is(ImmutableList.of(IDockerParameter.build(userParameter))));
   }
 
+  @Test
+  public void testExclusiveDedicatedRoleAllowed() throws Exception {
+    TaskConfig builder = UNSANITIZED_JOB_CONFIGURATION.deepCopy().getTaskConfig();
+    builder.setConstraints(ImmutableSet.of(new Constraint()
+        .setName(DEDICATED_ATTRIBUTE)
+        .setConstraint(TaskConstraint.value(
+            new ValueConstraint(false, ImmutableSet.of(JOB_KEY.getRole() + "/f"))))));
+
+    configurationManager.validateAndPopulate(ITaskConfig.build(builder));
+  }
+
+  @Test
+  public void testNonExclusiveDedicatedAllowed() throws Exception {
+    TaskConfig builder = UNSANITIZED_JOB_CONFIGURATION.deepCopy().getTaskConfig();
+    builder.setConstraints(ImmutableSet.of(new Constraint()
+        .setName(DEDICATED_ATTRIBUTE)
+        .setConstraint(TaskConstraint.value(new ValueConstraint(false, ImmutableSet.of("*/f"))))));
+
+    configurationManager.validateAndPopulate(ITaskConfig.build(builder));
+  }
+
+  @Test
+  public void testExclusiveDedicatedRoleMismatch() throws Exception {
+    TaskConfig builder = UNSANITIZED_JOB_CONFIGURATION.deepCopy().getTaskConfig();
+    builder.setConstraints(ImmutableSet.of(new Constraint()
+        .setName(DEDICATED_ATTRIBUTE)
+        .setConstraint(TaskConstraint.value(new ValueConstraint(false, ImmutableSet.of("r/f"))))));
+
+    expectTaskDescriptionException("Only r may use hosts dedicated for that role.");
+    configurationManager.validateAndPopulate(ITaskConfig.build(builder));
+  }
+
   private void expectTaskDescriptionException(String message) {
     expectedException.expect(TaskDescriptionException.class);
     expectedException.expectMessage(message);