With the new SpecialTask recovery code, a RepairTask can be passed a queue entry that was previously requeued.  So make sure the task leaves the HQE alone in that case.

Also delete some dead code that called requeue().

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


git-svn-id: http://test.kernel.org/svn/autotest/trunk@3411 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/scheduler/monitor_db.py b/scheduler/monitor_db.py
index 881fb4a..56898fb 100755
--- a/scheduler/monitor_db.py
+++ b/scheduler/monitor_db.py
@@ -1645,7 +1645,14 @@
         protection = host_protections.Protection.get_attr_name(protection)
 
         self.host = host
-        self.queue_entry = queue_entry
+        self.queue_entry = None
+        # recovery code can pass a HQE that's already been requeued. for a
+        # metahost, that means the host has been unassigned. in that case,
+        # ignore the HQE.
+        hqe_still_assigned_to_this_host = (queue_entry and queue_entry.host
+                                           and queue_entry.host.id == host.id)
+        if hqe_still_assigned_to_this_host:
+            self.queue_entry = queue_entry
 
         super(RepairTask, self).__init__(
                 task, ['-R', '--host-protection', protection],
@@ -1664,7 +1671,6 @@
             self.queue_entry.requeue()
 
 
-
     def _keyval_path(self):
         return os.path.join(self._working_directory, self._KEYVAL_FILE)
 
@@ -2412,25 +2418,6 @@
                'invalid', 'protection', 'locked_by_id', 'lock_time', 'dirty')
 
 
-    def current_task(self):
-        rows = _db.execute("""
-                SELECT * FROM host_queue_entries WHERE host_id=%s AND NOT complete AND active
-                """, (self.id,))
-
-        if len(rows) == 0:
-            return None
-        else:
-            assert len(rows) == 1
-            results = rows[0];
-            return HostQueueEntry(row=results)
-
-
-    def yield_work(self):
-        logging.info("%s yielding work", self.hostname)
-        if self.current_task():
-            self.current_task().requeue()
-
-
     def set_status(self,status):
         logging.info('%s -> %s', self.hostname, status)
         self.update_field('status',status)
@@ -2696,7 +2683,7 @@
             else:
                 assert assigned_host.id == self.host_id
 
-        logging.info("%s/%s/%s scheduled on %s, status=%s", 
+        logging.info("%s/%s/%s scheduled on %s, status=%s",
                      self.job.name, self.meta_host, self.atomic_group_id,
                      self.host.hostname, self.status)
 
@@ -2714,6 +2701,7 @@
 
 
     def requeue(self):
+        assert self.host
         self.set_status('Queued')
         self.update_field('started_on', None)
         # verify/cleanup failure sets the execution subdir, so reset it here