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

Side by Side Diff: appengine/swarming/server/task_request.py

Issue 2983203002: config_service: make UI adjustable for mobile (Closed)
Patch Set: config_service: prompt user to sign in when appropriate. Created 3 years, 4 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 unified diff | Download patch
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 # Copyright 2014 The LUCI Authors. All rights reserved. 2 # Copyright 2014 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 """Tasks definition. 6 """Tasks definition.
7 7
8 Each user request creates a new TaskRequest. The TaskRequest instance saves the 8 Each user request creates a new TaskRequest. The TaskRequest instance saves the
9 metadata of the request, e.g. who requested it, when why, etc. It links to the 9 metadata of the request, e.g. who requested it, when why, etc. It links to the
10 actual data of the request in a TaskProperties. The TaskProperties represents 10 actual data of the request in a TaskProperties. The TaskProperties represents
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 from server import config 68 from server import config
69 from server import task_pack 69 from server import task_pack
70 import acl 70 import acl
71 import cipd 71 import cipd
72 72
73 73
74 # Maximum acceptable priority value, which is effectively the lowest priority. 74 # Maximum acceptable priority value, which is effectively the lowest priority.
75 MAXIMUM_PRIORITY = 255 75 MAXIMUM_PRIORITY = 255
76 76
77 77
78 # One day in seconds. Add 10s to account for small jitter. 78 # Three days in seconds. Add 10s to account for small jitter.
79 _ONE_DAY_SECS = 24*60*60 + 10 79 _THREE_DAY_SECS = 3*24*60*60 + 10
80 80
81 81
82 # Seven day in seconds. Add 10s to account for small jitter. 82 # Seven day in seconds. Add 10s to account for small jitter.
83 _SEVEN_DAYS_SECS = 7*24*60*60 + 10 83 _SEVEN_DAYS_SECS = 7*24*60*60 + 10
84 84
85 85
86 # Minimum value for timeouts. 86 # Minimum value for timeouts.
87 _MIN_TIMEOUT_SECS = 1 if utils.is_local_dev_server() else 30 87 _MIN_TIMEOUT_SECS = 1 if utils.is_local_dev_server() else 30
88 88
89 89
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 def _validate_task_run_id(_prop, value): 220 def _validate_task_run_id(_prop, value):
221 """Validates a task_id looks valid without fetching the entity.""" 221 """Validates a task_id looks valid without fetching the entity."""
222 if not value: 222 if not value:
223 return None 223 return None
224 task_pack.unpack_run_result_key(value) 224 task_pack.unpack_run_result_key(value)
225 return value 225 return value
226 226
227 227
228 def _validate_timeout(prop, value): 228 def _validate_timeout(prop, value):
229 """Validates timeouts in seconds in TaskProperties.""" 229 """Validates timeouts in seconds in TaskProperties."""
230 if value and not (_MIN_TIMEOUT_SECS <= value <= _ONE_DAY_SECS): 230 if value and not (_MIN_TIMEOUT_SECS <= value <= _THREE_DAY_SECS):
231 # pylint: disable=W0212 231 # pylint: disable=W0212
232 raise datastore_errors.BadValueError( 232 raise datastore_errors.BadValueError(
233 '%s (%ds) must be 0 or between %ds and one day' % 233 '%s (%ds) must be 0 or between %ds and three days' %
234 (prop._name, value, _MIN_TIMEOUT_SECS)) 234 (prop._name, value, _MIN_TIMEOUT_SECS))
235 235
236 236
237 def _validate_tags(prop, value): 237 def _validate_tags(prop, value):
238 """Validates TaskRequest.tags.""" 238 """Validates TaskRequest.tags."""
239 _validate_length(prop, value, 1024) 239 _validate_length(prop, value, 1024)
240 if ':' not in value: 240 if ':' not in value:
241 # pylint: disable=W0212 241 # pylint: disable=W0212
242 raise datastore_errors.BadValueError( 242 raise datastore_errors.BadValueError(
243 '%s must be key:value form, not %s' % (prop._name, value)) 243 '%s must be key:value form, not %s' % (prop._name, value))
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 'Path "%s" is mapped to a named cache and cannot be a target ' 603 'Path "%s" is mapped to a named cache and cannot be a target '
604 'of CIPD installation' % p.path) 604 'of CIPD installation' % p.path)
605 if self.idempotent: 605 if self.idempotent:
606 pinned = lambda p: cipd.is_pinned_version(p.version) 606 pinned = lambda p: cipd.is_pinned_version(p.version)
607 assert self.cipd_input.packages # checked by cipd_input._pre_put_hook 607 assert self.cipd_input.packages # checked by cipd_input._pre_put_hook
608 if any(not pinned(p) for p in self.cipd_input.packages): 608 if any(not pinned(p) for p in self.cipd_input.packages):
609 raise datastore_errors.BadValueError( 609 raise datastore_errors.BadValueError(
610 'an idempotent task cannot have unpinned packages; ' 610 'an idempotent task cannot have unpinned packages; '
611 'use tags or instance IDs as package versions') 611 'use tags or instance IDs as package versions')
612 612
613 if len(self.outputs) > 2048: 613 if len(self.outputs) > 4096:
614 raise datastore_errors.BadValueError( 614 raise datastore_errors.BadValueError(
615 'Up to 2048 outputs can be listed for a task') 615 'Up to 4096 outputs can be listed for a task')
616 616
617 617
618 class TaskRequest(ndb.Model): 618 class TaskRequest(ndb.Model):
619 """Contains a user request. 619 """Contains a user request.
620 620
621 Key id is a decreasing integer based on time since utils.EPOCH plus some 621 Key id is a decreasing integer based on time since utils.EPOCH plus some
622 randomness on lower order bits. See new_request_key() for the complete gory 622 randomness on lower order bits. See new_request_key() for the complete gory
623 details. 623 details.
624 624
625 This model is immutable. 625 This model is immutable.
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 init_new_request(request, allow_high_priority, original_secret_bytes) 1014 init_new_request(request, allow_high_priority, original_secret_bytes)
1015 return request 1015 return request
1016 1016
1017 1017
1018 def validate_priority(priority): 1018 def validate_priority(priority):
1019 """Throws ValueError if priority is not a valid value.""" 1019 """Throws ValueError if priority is not a valid value."""
1020 if 0 > priority or MAXIMUM_PRIORITY < priority: 1020 if 0 > priority or MAXIMUM_PRIORITY < priority:
1021 raise datastore_errors.BadValueError( 1021 raise datastore_errors.BadValueError(
1022 'priority (%d) must be between 0 and %d (inclusive)' % 1022 'priority (%d) must be between 0 and %d (inclusive)' %
1023 (priority, MAXIMUM_PRIORITY)) 1023 (priority, MAXIMUM_PRIORITY))
OLDNEW
« no previous file with comments | « appengine/config_service/ui/test/config-ui/config-set_test.html ('k') | appengine/swarming/server/task_request_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698