Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1152)

Unified Diff: scripts/master/floating_builder.py

Issue 2255643002: Floating builder logic waits at startup. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | scripts/master/unittests/floating_builder_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/master/floating_builder.py
diff --git a/scripts/master/floating_builder.py b/scripts/master/floating_builder.py
index e11b35361c0d350a478c4ad8c511110da56432a2..968126fc1d133dfc9681b71deeca5823eaad7c4c 100644
--- a/scripts/master/floating_builder.py
+++ b/scripts/master/floating_builder.py
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import itertools
from datetime import datetime
from twisted.python import log
@@ -93,10 +94,13 @@ class _FloatingNextSlaveFunc(object):
self._primary, self._floating = fs.Get()
self._fs = fs
self._grace_period = grace_period
- self._slave_seen_times = {}
self._poke_builder_timers = {}
self.verbose = False
+ started = _get_now()
+ self._slave_seen_times = dict((s, started) for s in itertools.chain(
+ self._primary, self._floating))
+
def __repr__(self):
return '%s(%s)' % (type(self).__name__, self._fs)
@@ -184,13 +188,11 @@ class _FloatingNextSlaveFunc(object):
some_primary_were_busy = True
continue
+ # The slave is offline. Is this slave within the grace period?
+ #
bpastene 2016/08/17 01:22:13 nit: remove line
dnj 2016/08/17 01:24:17 Done.
# Get the 'SlaveStatus' object for this slave
slave_status = slave_status_map.get(slave_name)
- if slave_status is None:
- continue
-
- # The slave is offline. Is this slave within the grace period?
- last_seen = self._get_latest_seen_time(slave_status)
+ last_seen = self._get_latest_seen_time(slave_name, slave_status)
if last_seen < grace_threshold:
# No, the slave is older than our grace period.
self._debug('Slave [%s] is OFFLINE and outside grace period '
@@ -254,20 +256,16 @@ class _FloatingNextSlaveFunc(object):
return [slave_builder.slave.slave_status
for slave_builder in builder.slaves]
- def _get_latest_seen_time(self, slave_status):
- times = []
-
- # Add all of the registered connect times
- times += [datetime.fromtimestamp(connect_time)
- for connect_time in slave_status.connect_times]
+ def _get_latest_seen_time(self, slave_name, slave_status):
+ times = [self._slave_seen_times[slave_name]]
- # Add the time of the slave's last message
- times.append(datetime.fromtimestamp(slave_status.lastMessageReceived()))
+ if slave_status:
+ # Add all of the registered connect times
+ times += [datetime.fromtimestamp(connect_time)
+ for connect_time in slave_status.connect_times]
- # Add the last time we've seen the slave in our 'nextSlave' function
- last_seen_time = self._slave_seen_times.get(slave_status.name)
- if last_seen_time is not None:
- times.append(last_seen_time)
+ # Add the time of the slave's last message
+ times.append(datetime.fromtimestamp(slave_status.lastMessageReceived()))
if not times:
bpastene 2016/08/17 01:22:13 OOC, would times ever be empty here? If I'm readin
dnj 2016/08/17 01:24:17 Oh yeah that's not needed anymore.
return None
« no previous file with comments | « no previous file | scripts/master/unittests/floating_builder_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698