fix Agent.abort() when it's called before the agent has started (in that case, it should do nothing -- but the logic was making it basically ignore the abort).  this should fix jobs being aborting in the "starting" phase (a phase that lasts one cycle before "running" starts).

Signed-off-by: Steve Howard <showard@google.com>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@3060 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/scheduler/monitor_db.py b/scheduler/monitor_db.py
index cb7eea1..a9c7b0f 100755
--- a/scheduler/monitor_db.py
+++ b/scheduler/monitor_db.py
@@ -1173,9 +1173,12 @@
     def abort(self):
         if self.active_task:
             self.active_task.abort()
-            if self.active_task.aborted: # tasks can choose to ignore aborts
-                self.active_task = None
-                self._clear_queue()
+            if not self.active_task.aborted: # tasks can choose to ignore aborts
+                return
+            self.active_task = None
+
+        self._clear_queue()
+
 
 
 class AgentTask(object):
diff --git a/scheduler/monitor_db_unittest.py b/scheduler/monitor_db_unittest.py
index c56cb0d..5b6f80b 100644
--- a/scheduler/monitor_db_unittest.py
+++ b/scheduler/monitor_db_unittest.py
@@ -1297,6 +1297,15 @@
         self._test_agent_abort_helper(True)
 
 
+    def test_agent_abort_before_started(self):
+        task = self._create_mock_task('task')
+        agent = self._create_agent([task])
+        agent.abort()
+        agent.start()
+        self._finish_agent(agent)
+        self.god.check_playback()
+
+
 class AgentTasksTest(unittest.TestCase):
     TEMP_DIR = '/abspath/tempdir'
     RESULTS_DIR = '/results/dir'