aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject git commit: Dropping "No jobs to kill" error from killTasks.
Date Wed, 30 Apr 2014 19:15:24 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 953bf836b -> bfd92299f


Dropping "No jobs to kill" error from killTasks.

Bugs closed: AURORA-345

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


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

Branch: refs/heads/master
Commit: bfd92299fbf7476aa3c2b90e7b59144da9534c45
Parents: 953bf83
Author: Maxim Khutornenko <maxim@apache.org>
Authored: Wed Apr 30 12:15:06 2014 -0700
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Wed Apr 30 12:15:06 2014 -0700

----------------------------------------------------------------------
 .../aurora/scheduler/state/SchedulerCore.java   |  3 +--
 .../scheduler/state/SchedulerCoreImpl.java      | 23 +++++---------------
 .../thrift/SchedulerThriftInterface.java        |  2 --
 .../state/BaseSchedulerCoreImplTest.java        |  9 +++++++-
 .../thrift/SchedulerThriftInterfaceTest.java    |  7 +++---
 5 files changed, 17 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/bfd92299/src/main/java/org/apache/aurora/scheduler/state/SchedulerCore.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/state/SchedulerCore.java b/src/main/java/org/apache/aurora/scheduler/state/SchedulerCore.java
index e62f6c6..226b71c 100644
--- a/src/main/java/org/apache/aurora/scheduler/state/SchedulerCore.java
+++ b/src/main/java/org/apache/aurora/scheduler/state/SchedulerCore.java
@@ -76,9 +76,8 @@ public interface SchedulerCore {
    *
    * @param query Builder for a query to identify tasks
    * @param user Name of the user performing the kill.
-   * @throws ScheduleException If a problem occurs with the kill request.
    */
-  void killTasks(Query.Builder query, String user) throws ScheduleException;
+  void killTasks(Query.Builder query, String user);
 
   /**
    * Initiates a restart of shards within an active job.

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/bfd92299/src/main/java/org/apache/aurora/scheduler/state/SchedulerCoreImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/state/SchedulerCoreImpl.java b/src/main/java/org/apache/aurora/scheduler/state/SchedulerCoreImpl.java
index 5369279..f330599 100644
--- a/src/main/java/org/apache/aurora/scheduler/state/SchedulerCoreImpl.java
+++ b/src/main/java/org/apache/aurora/scheduler/state/SchedulerCoreImpl.java
@@ -206,20 +206,17 @@ class SchedulerCoreImpl implements SchedulerCore {
   }
 
   @Override
-  public synchronized void killTasks(Query.Builder query, final String user)
-      throws ScheduleException {
+  public synchronized void killTasks(Query.Builder query, final String user) {
 
     checkNotNull(query);
     LOG.info("Killing tasks matching " + query);
 
-    boolean cronDeleted = false;
-
     if (Query.isSingleJobScoped(query)) {
       // If this looks like a query for all tasks in a job, instruct the cron scheduler to
delete
       // it.
       // TODO(maxim): Should be trivial to support killing multiple jobs instead.
       IJobKey jobKey = Iterables.getOnlyElement(JobKeys.from(query).get());
-      cronDeleted = cronScheduler.deleteJob(jobKey);
+      cronScheduler.deleteJob(jobKey);
     }
 
     // Unless statuses were specifically supplied, only attempt to kill active tasks.
@@ -227,28 +224,18 @@ class SchedulerCoreImpl implements SchedulerCore {
         ? query.byStatus(ACTIVE_STATES)
         : query;
 
-    int tasksAffected = storage.write(new MutateWork.Quiet<Integer>() {
+    storage.write(new MutateWork.NoResult.Quiet() {
       @Override
-      public Integer apply(MutableStoreProvider storeProvider) {
-        int total = 0;
+      public void execute(MutableStoreProvider storeProvider) {
         for (String taskId : Tasks.ids(storeProvider.getTaskStore().fetchTasks(taskQuery)))
{
-          boolean changed = stateManager.changeState(
+          stateManager.changeState(
               taskId,
               Optional.<ScheduleStatus>absent(),
               KILLING,
               Optional.of("Killed by " + user));
-
-          if (changed) {
-            total++;
-          }
         }
-        return total;
       }
     });
-
-    if (!cronDeleted && (tasksAffected == 0)) {
-      throw new ScheduleException("No jobs to kill");
-    }
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/bfd92299/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
index e69daa6..abf47d7 100644
--- a/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
+++ b/src/main/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterface.java
@@ -566,8 +566,6 @@ class SchedulerThriftInterface implements AuroraAdmin.Iface {
       schedulerCore.killTasks(Query.arbitrary(query), context.get().getIdentity());
     } catch (LockException e) {
       return response.setResponseCode(LOCK_ERROR).setMessage(e.getMessage());
-    } catch (ScheduleException e) {
-      return response.setResponseCode(INVALID_REQUEST).setMessage(e.getMessage());
     }
 
     // TODO(William Farner): Move this into the client.

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/bfd92299/src/test/java/org/apache/aurora/scheduler/state/BaseSchedulerCoreImplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/state/BaseSchedulerCoreImplTest.java
b/src/test/java/org/apache/aurora/scheduler/state/BaseSchedulerCoreImplTest.java
index d7dbfaa..da6c0ff 100644
--- a/src/test/java/org/apache/aurora/scheduler/state/BaseSchedulerCoreImplTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/state/BaseSchedulerCoreImplTest.java
@@ -616,13 +616,20 @@ public abstract class BaseSchedulerCoreImplTest extends EasyMockTest
{
         assertEquals(KILLING, getTask(taskId).getStatus());
       }
 
-      // SImulate a KILLED ack from the executor.
+      // Simulate a KILLED ack from the executor.
       changeStatus(Query.roleScoped(ROLE_A), KILLED);
       assertTrue(
           getTasks(Query.jobScoped(KEY_A).active()).isEmpty());
     }
   }
 
+  @Test
+  public void testKillNoTasksDoesNotThrow() throws Exception {
+    control.replay();
+    buildScheduler();
+    scheduler.killTasks(Query.roleScoped("role_absent"), OWNER_A.getUser());
+  }
+
   private IExpectationSetters<Long> expectTaskNotThrottled() {
     return expect(rescheduleCalculator.getFlappingPenaltyMs(EasyMock.<IScheduledTask>anyObject()))
         .andReturn(0L);

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/bfd92299/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
index 7215555..169c403 100644
--- a/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/thrift/SchedulerThriftInterfaceTest.java
@@ -421,17 +421,16 @@ public class SchedulerThriftInterfaceTest extends EasyMockTest {
 
   @Test
   public void testKillNonExistentTasks() throws Exception {
-    Query.Builder query = Query.unscoped().byJob(JOB_KEY);
+    Query.Builder query = Query.unscoped().byJob(JOB_KEY).active();
 
     expectAuth(ROOT, true);
 
     scheduler.killTasks(query, USER);
-    expectLastCall().andThrow(new ScheduleException("No jobs matching query"));
-    storageUtil.expectTaskFetch(query);
+    storageUtil.expectTaskFetch(query).times(2);
 
     control.replay();
 
-    assertResponse(INVALID_REQUEST, thrift.killTasks(query.get(), DEFAULT_LOCK, SESSION));
+    assertOkResponse(thrift.killTasks(query.get(), DEFAULT_LOCK, SESSION));
   }
 
   @Test


Mime
View raw message