when "stopping" a sync job, don't stop verifying entries, because they still have active agents holding HostQueueEntry objects, and messing with them creates data inconsistencies. this is a symptom of a larger problem with the DB models in the scheduler, but I'm not sure how to fix the larger problem right now.
Signed-off-by: Steve Howard <showard@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@2717 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/scheduler/monitor_db.py b/scheduler/monitor_db.py
index 48b205a..b872cfe 100644
--- a/scheduler/monitor_db.py
+++ b/scheduler/monitor_db.py
@@ -2040,11 +2040,19 @@
return self.num_complete() == self.num_machines()
- def _stop_all_entries(self, entries_to_abort):
- """
- queue_entries: sequence of models.HostQueueEntry objects
- """
- for child_entry in entries_to_abort:
+ def _not_yet_run_entries(self, include_verifying=True):
+ statuses = [models.HostQueueEntry.Status.QUEUED,
+ models.HostQueueEntry.Status.PENDING]
+ if include_verifying:
+ statuses.append(models.HostQueueEntry.Status.VERIFYING)
+ return models.HostQueueEntry.objects.filter(job=self.id,
+ status__in=statuses)
+
+
+ def _stop_all_entries(self):
+ entries_to_stop = self._not_yet_run_entries(
+ include_verifying=False)
+ for child_entry in entries_to_stop:
assert not child_entry.complete, (
'%s status=%s, active=%s, complete=%s' %
(child_entry.id, child_entry.status, child_entry.active,
@@ -2055,14 +2063,10 @@
child_entry.status = models.HostQueueEntry.Status.STOPPED
child_entry.save()
-
def stop_if_necessary(self):
- not_yet_run = models.HostQueueEntry.objects.filter(
- job=self.id, status__in=(models.HostQueueEntry.Status.QUEUED,
- models.HostQueueEntry.Status.VERIFYING,
- models.HostQueueEntry.Status.PENDING))
+ not_yet_run = self._not_yet_run_entries()
if not_yet_run.count() < self.synch_count:
- self._stop_all_entries(not_yet_run)
+ self._stop_all_entries()
def write_to_machines_file(self, queue_entry):