[autotest] Fix SelfThrottledTask._num_running_processes when suite job is aborted
When suite job is aborted, the variable SelfThrottledTask._num_running_processes
is not decremented. The cause is that abort call AbstractQueueTask.abort
bypasses call on SelfThrottledTask.finished.
Change is made in Agent.abort method. When a task is aborted from an AgentTask,
BaseAgentTask.finished(False) is called to allow finished method in
SelfThrottledTask to be called to update the counters properly.
BUG=chromium:288175
TEST=unittest,
add logging in SelfThrottleTask._increment_running_processes and
_decrement_running_processes methods to print out value of
_num_running_processes. Start scheduler (monitor_db) in local workstation,
create several suite jobs via run_suite, cancel some of the suite jobs. After
all jobs are finished or aborted, confirm value of _num_running_processes are
all 0.
Change-Id: I80545fc68a75db645c9b8b5330b05b64e7609a9d
Reviewed-on: https://chromium-review.googlesource.com/168649
Reviewed-by: Alex Miller <milleral@chromium.org>
Tested-by: Dan Shi <dshi@chromium.org>
Commit-Queue: Dan Shi <dshi@chromium.org>
diff --git a/scheduler/monitor_db.py b/scheduler/monitor_db.py
index b9924a6..fa1e7b7 100755
--- a/scheduler/monitor_db.py
+++ b/scheduler/monitor_db.py
@@ -1374,7 +1374,6 @@
self.success)
-
def start(self):
if not self.started:
self.prolog()
@@ -1389,6 +1388,8 @@
self.done = True
self.aborted = True
self.cleanup()
+ if self.started:
+ self.finished(success=False)
def _get_consistent_execution_path(self, execution_entries):
@@ -1677,11 +1678,15 @@
@classmethod
def _increment_running_processes(cls):
cls._num_running_processes += 1
+ stats.Gauge('scheduler').send('%s.num_running_processes' % cls.__name__,
+ cls._num_running_processes)
@classmethod
def _decrement_running_processes(cls):
cls._num_running_processes -= 1
+ stats.Gauge('scheduler').send('%s.num_running_processes' % cls.__name__,
+ cls._num_running_processes)
@classmethod
@@ -1761,7 +1766,6 @@
self._decrement_running_processes()
-
class SpecialAgentTask(AgentTask, TaskWithJobKeyvals):
"""
Subclass for AgentTasks that correspond to a SpecialTask entry in the DB.