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

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

Issue 1942143002: swarming: isolate defaults (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@swarming-ns-re
Patch Set: rebased Created 4 years, 7 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 | « appengine/swarming/proto/config_pb2.py ('k') | appengine/swarming/server/config_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/swarming/server/config.py
diff --git a/appengine/swarming/server/config.py b/appengine/swarming/server/config.py
index dbd6699a838f550ee746806fe4cefc6c515beacc..0615f9484db15cad2f114a4cf93e9d0d0e7367b8 100644
--- a/appengine/swarming/server/config.py
+++ b/appengine/swarming/server/config.py
@@ -14,20 +14,35 @@ from components import utils
from components.config import validation
from proto import config_pb2
+from server import task_request
+
SETTINGS_CFG_FILENAME = 'settings.cfg'
+SECONDS_IN_YEAR = 60 * 60 * 24 * 365
ConfigApi = config.ConfigApi
+def validate_isolate_settings(cfg, ctx):
+ if bool(cfg.default_server) != bool(cfg.default_namespace):
+ ctx.error(
+ 'either specify both default_server and default_namespace or none')
+ elif cfg.default_server:
+ if not cfg.default_server.startswith(('https://', 'http://')):
+ ctx.error('default_server must start with "https://" or "http://"')
+
+ if not task_request.NAMESPACE_RE.match(cfg.default_namespace):
+ ctx.error('invalid namespace "%s"', cfg.default_namespace)
+
+
@validation.self_rule(SETTINGS_CFG_FILENAME, config_pb2.SettingsCfg)
def validate_settings(cfg, ctx):
"""Validates settings.cfg file against proto message schema."""
def within_year(value):
if value < 0:
ctx.error('cannot be negative')
- elif value > 60 * 60 * 24 * 365:
+ elif value > SECONDS_IN_YEAR:
ctx.error('cannot be more than a year')
with ctx.prefix('bot_death_timeout_secs '):
@@ -35,6 +50,10 @@ def validate_settings(cfg, ctx):
with ctx.prefix('reusable_task_age_secs '):
within_year(cfg.reusable_task_age_secs)
+ if cfg.HasField('isolate'):
+ with ctx.prefix('isolate: '):
+ validate_isolate_settings(cfg.isolate, ctx)
+
@utils.memcache('config:get_configs_url', time=60)
def _get_configs_url():
« no previous file with comments | « appengine/swarming/proto/config_pb2.py ('k') | appengine/swarming/server/config_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698