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

Side by Side Diff: appengine/swarming/server/bot_management.py

Issue 1458553003: Delete old APIs on both Swarming and Isolate servers. (Closed) Base URL: git@github.com:luci/luci-py.git@1_warning
Patch Set: Rebasing on HEAD Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « appengine/swarming/handlers_frontend.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Swarming Authors. All rights reserved. 1 # Copyright 2014 The Swarming Authors. All rights reserved.
2 # Use of this source code is governed by the Apache v2.0 license that can be 2 # Use of this source code is governed by the Apache v2.0 license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Swarming bot management, e.g. list of known bots and their state. 5 """Swarming bot management, e.g. list of known bots and their state.
6 6
7 +---------+ 7 +---------+
8 |BotRoot | 8 |BotRoot |
9 |id=bot_id| 9 |id=bot_id|
10 +---------+ 10 +---------+
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 seed = ord(seed_bytes[0]) + 256 * ord(seed_bytes[1]) 288 seed = ord(seed_bytes[0]) + 256 * ord(seed_bytes[1])
289 factor = 2 * (seed - 32768) / 65536.0 * BOT_REBOOT_PERIOD_RANDOMIZATION_MARGIN 289 factor = 2 * (seed - 32768) / 65536.0 * BOT_REBOOT_PERIOD_RANDOMIZATION_MARGIN
290 return int(periodic_reboot_secs * (1.0 + factor)) 290 return int(periodic_reboot_secs * (1.0 + factor))
291 291
292 292
293 def should_restart_bot(bot_id, state): 293 def should_restart_bot(bot_id, state):
294 """Decides whether a bot needs to be restarted. 294 """Decides whether a bot needs to be restarted.
295 295
296 Args: 296 Args:
297 bot_id: ID of the bot. 297 bot_id: ID of the bot.
298 state: A dictionary representing current bot state, see 298 state: dict representing current bot state.
299 handlers_api.BotPollHandler for the list of keys.
300 299
301 Returns: 300 Returns:
302 Tuple (True to restart, text message explaining the reason). 301 Tuple (True to restart, text message explaining the reason).
303 """ 302 """
304 # Periodically reboot bots to workaround OS level leaks (especially on Win). 303 # Periodically reboot bots to workaround OS level leaks (especially on Win).
305 running_time = state.get('running_time', 0) 304 running_time = state.get('running_time', 0)
306 assert isinstance(running_time, (int, float)) 305 assert isinstance(running_time, (int, float))
307 period = get_bot_reboot_period(bot_id, state) 306 period = get_bot_reboot_period(bot_id, state)
308 if period and running_time > period: 307 if period and running_time > period:
309 return True, 'Periodic reboot: running longer than %ds' % period 308 return True, 'Periodic reboot: running longer than %ds' % period
310 return False, '' 309 return False, ''
OLDNEW
« no previous file with comments | « appengine/swarming/handlers_frontend.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698