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

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

Issue 2926713004: Add support for repeated keys in TaskRequest. (Closed)
Patch Set: rebase Created 3 years, 6 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/server/task_result_test.py ('k') | appengine/swarming/server/task_scheduler_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/swarming/server/task_scheduler.py
diff --git a/appengine/swarming/server/task_scheduler.py b/appengine/swarming/server/task_scheduler.py
index 58714dfa3bdfd36f7fb2ec5cbbaa171ba04886dc..d6c640389817a52a6b7ba58f808542703f2066f6 100644
--- a/appengine/swarming/server/task_scheduler.py
+++ b/appengine/swarming/server/task_scheduler.py
@@ -350,19 +350,20 @@ def _check_dimension_acls(request):
ident = request.authenticated
dims = request.properties.dimensions
- assert 'id' in dims or 'pool' in dims, dims # see _validate_dimensions
assert ident is not None # see task_request.init_new_request
+ using_id = any(k == u'id' for k, _ in dims)
+ using_pool = any(k == u'pool' for k, _ in dims)
# Forbid targeting individual bots for non-admins, but allow using 'id' if
# 'pool' is used as well (so whoever can posts tasks to 'pool', can target an
# individual bot in that pool).
- if 'id' in dims and 'pool' not in dims:
+ if using_id and not using_pool:
if not acl.is_admin():
raise auth.AuthorizationError(
'Only Swarming administrators can post tasks with "id" dimension '
'without specifying a "pool" dimension.')
- for k, v in sorted(dims.iteritems()):
+ for k, v in dims:
if not _can_use_dimension(dim_acls, ident, k, v):
raise auth.AuthorizationError(
'User %s is not allowed to schedule tasks with dimension "%s:%s"' %
« no previous file with comments | « appengine/swarming/server/task_result_test.py ('k') | appengine/swarming/server/task_scheduler_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698