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

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

Issue 2689483004: swarming: Add server-side implementation for supplemental bot_config (Closed)
Patch Set: Bot side fix Created 3 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 side-by-side diff with in-line comments
Download patch
Index: appengine/swarming/server/bot_groups_config.py
diff --git a/appengine/swarming/server/bot_groups_config.py b/appengine/swarming/server/bot_groups_config.py
index 962a36087159b45a6dc360a5e357410a9ba8def0..547c7c0a6ff850f6195f12f91b4d83907f617d5e 100644
--- a/appengine/swarming/server/bot_groups_config.py
+++ b/appengine/swarming/server/bot_groups_config.py
@@ -7,6 +7,7 @@
import collections
import hashlib
import logging
+import os
import re
from components import auth
@@ -47,6 +48,10 @@ BotGroupConfig = collections.namedtuple('BotGroupConfig', [
# dimension from that set, the list of value for it will be empty. Key and
# values are unicode strings.
'dimensions',
+
+ # Name of the supplemental bot_config.py to inject to the bot during
+ # handshake.
+ 'bot_config_script',
])
@@ -71,7 +76,8 @@ _DEFAULT_BOT_GROUPS = _BotGroups(
require_service_account=None,
ip_whitelist=auth.BOTS_IP_WHITELIST,
owners=(),
- dimensions={}))
+ dimensions={},
+ bot_config_script=''))
def _gen_version(fields):
@@ -145,7 +151,8 @@ def _bot_group_proto_to_tuple(msg, trusted_dimensions):
require_service_account=auth_cfg.require_service_account,
ip_whitelist=auth_cfg.ip_whitelist,
owners=tuple(msg.owners),
- dimensions={k: sorted(v) for k, v in dimensions.iteritems()})
+ dimensions={k: sorted(v) for k, v in dimensions.iteritems()},
+ bot_config_script=msg.bot_config_script)
def _expand_bot_id_expr(expr):
@@ -392,6 +399,16 @@ def validate_settings(cfg, ctx):
if not local_config.validate_flat_dimension(dim):
ctx.error('bad dimension %r', dim)
+ # Validate 'bot_config_script': the supplemental bot_config.py.
+ if entry.bot_config_script:
+ # Another check confirms that the script itself is valid python.
+ if not entry.bot_config_script.endswith('.py'):
+ ctx.error('Invalid bot_config_script name')
+ if os.path.basename(entry.bot_config_script) != entry.bot_config_script:
+ ctx.error('Invalid bot_config_script name')
+ # We can't validate that the file exists here. It'll generate an HTTP
+ # 500 at handshake time.
+
# Now verify bot_id_prefix is never a prefix of other prefix. It causes
# ambiguities.
for smaller, s_idx in bot_id_prefixes.iteritems():

Powered by Google App Engine
This is Rietveld 408576698