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

Unified Diff: appengine/swarming/server/bot_management.py

Issue 2402543002: Create a BotEvent when a bot is leased from Machine Provider (Closed)
Patch Set: Created 4 years, 2 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
Index: appengine/swarming/server/bot_management.py
diff --git a/appengine/swarming/server/bot_management.py b/appengine/swarming/server/bot_management.py
index 6a01af7ae72f41ba6f391e19d4072b35099d7d51..a2fc124d09b79e0d20363c85fb065fb43083c566 100644
--- a/appengine/swarming/server/bot_management.py
+++ b/appengine/swarming/server/bot_management.py
@@ -84,6 +84,12 @@ class _BotCommon(ndb.Model):
# 'task_error'.
task_id = ndb.StringProperty(indexed=False)
+ # Machine Provider lease ID, for bots acquired from Machine Provider.
+ lease_id = ndb.StringProperty(indexed=False)
+
+ # UTC seconds from epoch when bot will be reclaimed by Machine Provider.
+ lease_expiration_ts = ndb.DateTimeProperty()
M-A Ruel 2016/10/06 23:37:28 I'd say indexed=False here too (?)
smut 2016/10/06 23:48:50 Done. I thought it was default False for DateTimeP
+
@property
def dimensions(self):
"""Returns a dict representation of self.dimensions_flat."""
@@ -175,8 +181,8 @@ class BotEvent(_BotCommon):
This entity is created on each bot state transition.
"""
ALLOWED_EVENTS = {
- 'bot_connected', 'bot_error', 'bot_log', 'bot_rebooting', 'bot_shutdown',
- 'bot_terminate',
+ 'bot_connected', 'bot_error', 'bot_leased', 'bot_log', 'bot_rebooting',
+ 'bot_shutdown', 'bot_terminate',
'request_restart', 'request_update', 'request_sleep', 'request_task',
'task_completed', 'task_error', 'task_update',
}
@@ -312,6 +318,9 @@ def bot_event(
- task_id: packed task id if relevant. Set to '' to zap the stored value.
- task_name: task name if relevant. Zapped when task_id is zapped.
- kwargs: optional values to add to BotEvent relevant to event_type.
+ - lease_id (in kwargs): ID assigned by Machine Provider for this bot.
+ - lease_expiration_ts (in kwargs): UTC seconds from epoch when Machine
+ Provider lease expires.
"""
if not bot_id:
return
@@ -334,6 +343,10 @@ def bot_event(
bot_info.task_name = task_name
if version is not None:
bot_info.version = version
+ if kwargs.get('lease_id') is not None:
+ bot_info.lease_id = kwargs['lease_id']
+ if kwargs.get('lease_expiration_ts') is not None:
+ bot_info.lease_expiration_ts = kwargs['lease_expiration_ts']
if event_type in ('request_sleep', 'task_update'):
# Handle this specifically. It's not much of an even worth saving a BotEvent
« no previous file with comments | « no previous file | appengine/swarming/server/lease_management.py » ('j') | appengine/swarming/server/lease_management.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698