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

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

Issue 2856733002: swarming: add transaction_id to tasks.new request
Patch Set: nits Created 3 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
Index: appengine/swarming/server/task_scheduler.py
diff --git a/appengine/swarming/server/task_scheduler.py b/appengine/swarming/server/task_scheduler.py
index 0d79b0562b7585b3d569635a0055360d48f56c91..c99e81c2796d66e9fd065b5ffe43019b1b34a410 100644
--- a/appengine/swarming/server/task_scheduler.py
+++ b/appengine/swarming/server/task_scheduler.py
@@ -12,6 +12,7 @@ import logging
import math
import random
+from google.appengine.api import memcache
from google.appengine.ext import ndb
from components import auth
@@ -474,14 +475,17 @@ def exponential_backoff(attempt_num):
return min(max_wait, math.pow(1.5, min(attempt_num, 10) + 1))
-def schedule_request(request, secret_bytes, check_acls=True):
+def schedule_request(
+ request, secret_bytes, check_acls=True,
+ memcache_key_for_task_id=None, memcache_ns_for_task_id=None):
"""Creates and stores all the entities to schedule a new task request.
Checks ACLs first. Raises auth.AuthorizationError if caller is not authorized
to post this request.
The number of entities created is 3: TaskRequest, TaskToRun and
- TaskResultSummary.
+ TaskResultSummary. If memcache_key_for_task_id is not None, sets it to the
+ task_id right after creation.
All 4 entities in the same entity group (TaskReqest, TaskToRun,
TaskResultSummary, SecretBytes) are saved as a DB transaction.
@@ -566,6 +570,10 @@ def schedule_request(request, secret_bytes, check_acls=True):
# be run but the client will not know about it.
datastore_utils.insert(request, get_new_keys,
extra=filter(bool, [task, result_summary, secret_bytes]))
+ if memcache_key_for_task_id:
+ memcache.set(
+ memcache_key_for_task_id, result_summary.task_id,
+ namespace=memcache_ns_for_task_id)
logging.debug('New request %s', result_summary.task_id)
# Get parent task details if applicable.

Powered by Google App Engine
This is Rietveld 408576698