Don't try stopping the job on HQE abort, and have the dispatcher stop all
necessary jobs in bulk. This avoids a scheduler crash on an assertion.

Signed-off-by: James Ren <[email protected]>

--- autotest/scheduler/monitor_db.py    2010-06-04 17:02:35.000000000 -0700
+++ autotest/scheduler/monitor_db.py    2010-06-04 17:02:35.000000000 -0700
@@ -1130,12 +1130,16 @@
 
 
     def _find_aborting(self):
+        jobs_to_stop = set()
         for entry in scheduler_models.HostQueueEntry.fetch(
                 where='aborted and not complete'):
             logging.info('Aborting %s', entry)
             for agent in self.get_agents_for_entry(entry):
                 agent.abort()
             entry.abort(self)
+            jobs_to_stop.add(entry.job)
+        for job in jobs_to_stop:
+            job.stop_if_necessary()
 
 
     def _can_start_agent(self, agent, num_started_this_cycle,
--- autotest/scheduler/monitor_db_functional_test.py    2010-06-04 
17:02:35.000000000 -0700
+++ autotest/scheduler/monitor_db_functional_test.py    2010-06-04 
17:02:35.000000000 -0700
@@ -667,6 +667,19 @@
         self._finish_parsing_and_cleanup(queue_entry)
 
 
+    def test_job_abort_queued_synchronous(self):
+        self._initialize_test()
+        job = self._create_job(hosts=[1,2])
+        job.synch_count = 2
+        job.save()
+
+        job.hostqueueentry_set.update(aborted=True)
+        self._run_dispatcher()
+        for host_queue_entry in job.hostqueueentry_set.all():
+            self.assertEqual(host_queue_entry.status,
+                             HqeStatus.ABORTED)
+
+
     def test_no_pidfile_leaking(self):
         self._initialize_test()
         self.test_simple_job()
--- autotest/scheduler/scheduler_models.py      2010-06-04 17:02:35.000000000 
-0700
+++ autotest/scheduler/scheduler_models.py      2010-06-04 17:02:35.000000000 
-0700
@@ -569,7 +569,7 @@
         self.update_field('complete', complete)
 
         if complete:
-            self._on_complete()
+            self._on_complete(status)
             self._email_on_job_complete()
 
         should_email_status = (status.lower() in _notify_email_statuses or
@@ -578,8 +578,10 @@
             self._email_on_status(status)
 
 
-    def _on_complete(self):
-        self.job.stop_if_necessary()
+    def _on_complete(self, status):
+        if status is not models.HostQueueEntry.Status.ABORTED:
+            self.job.stop_if_necessary()
+
         if not self.execution_subdir:
             return
         # unregister any possible pidfiles associated with this queue entry
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to