Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The LUCI Authors. All rights reserved. | 1 # Copyright 2014 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 | 204 |
| 205 Parent is BotRoot. Key id is 'settings'. | 205 Parent is BotRoot. Key id is 'settings'. |
| 206 | 206 |
| 207 This entity must always be updated in a transaction. | 207 This entity must always be updated in a transaction. |
| 208 """ | 208 """ |
| 209 # If set to True, no task is handed out to this bot due to the bot being in a | 209 # If set to True, no task is handed out to this bot due to the bot being in a |
| 210 # broken situation. | 210 # broken situation. |
| 211 quarantined = ndb.BooleanProperty() | 211 quarantined = ndb.BooleanProperty() |
| 212 | 212 |
| 213 | 213 |
| 214 class DimensionValues(ndb.Model): | |
| 215 dimension = ndb.StringProperty() | |
|
M-A Ruel
2016/08/05 14:36:05
key = ndb.StringProperty()
kjlubick
2016/08/05 17:38:58
"Don't name a property "key." This name is reserve
M-A Ruel
2016/08/05 18:06:00
Ugh, I forgot about that.
| |
| 216 values = ndb.StringProperty(repeated=True) | |
| 217 | |
| 218 | |
| 219 class DimensionAggregation(ndb.Model): | |
| 220 """Has all dimensions that are currently in use.""" | |
| 221 dimensions = ndb.LocalStructuredProperty(DimensionValues, repeated=True) | |
| 222 | |
| 223 ts = ndb.DateTimeProperty(auto_now_add=True) | |
|
M-A Ruel
2016/08/05 14:36:05
ts = ndb.DateTimeProperty()
KEY = ndb.Key(Dimens
kjlubick
2016/08/05 17:38:58
Done.
| |
| 224 | |
| 225 | |
| 214 ### Private APIs. | 226 ### Private APIs. |
| 215 | 227 |
| 216 | 228 |
| 217 ### Public APIs. | 229 ### Public APIs. |
| 218 | 230 |
| 219 | 231 |
| 220 def dimensions_to_flat(dimensions): | 232 def dimensions_to_flat(dimensions): |
| 221 out = [] | 233 out = [] |
| 222 for k, values in dimensions.iteritems(): | 234 for k, values in dimensions.iteritems(): |
| 223 for v in values: | 235 for v in values: |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 353 Returns: | 365 Returns: |
| 354 Tuple (True to restart, text message explaining the reason). | 366 Tuple (True to restart, text message explaining the reason). |
| 355 """ | 367 """ |
| 356 # Periodically reboot bots to workaround OS level leaks (especially on Win). | 368 # Periodically reboot bots to workaround OS level leaks (especially on Win). |
| 357 running_time = state.get('running_time', 0) | 369 running_time = state.get('running_time', 0) |
| 358 assert isinstance(running_time, (int, float)) | 370 assert isinstance(running_time, (int, float)) |
| 359 period = get_bot_reboot_period(bot_id, state) | 371 period = get_bot_reboot_period(bot_id, state) |
| 360 if period and running_time > period: | 372 if period and running_time > period: |
| 361 return True, 'Periodic reboot: running longer than %ds' % period | 373 return True, 'Periodic reboot: running longer than %ds' % period |
| 362 return False, '' | 374 return False, '' |
| OLD | NEW |