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

Issue 2856733002: swarming: add transaction_id to tasks.new request

Created:
3 years, 7 months ago by nodir
Modified:
3 years, 7 months ago
Reviewers:
Vadim Sh., M-A Ruel
CC:
chromium-reviews, infra-reviews+luci-py_chromium.org
Target Ref:
refs/heads/master
Project:
luci-py
Visibility:
Public.

Description

swarming: add transaction_id to tasks.new request tasks.new RPCs are not safe to repeat on transient errors beacuse tasks.new is not idempotent. Also it is possible that a task creation request was served, but the client did not receieve the response due to network. In this case it is not possible to ensure the task does not exist. Add transaction_id to NewTaskRequest. It serves two purposes: - it makes tasks.new API "more" idempotent: if a second request with the same transaction id is received and a task already exists, the handler reuses existing task. This allow a client to retry tasks.new requests on transient failures. - serves as a second, temporary, identity of the task: a user can cancel a task by transaction id. Internally task_id is stored in the memcache entry with a key derived from transaction id. Also this CL fixes some tests. R=maruel@chromium.org, vadimsh@chromium.org BUG=713307

Patch Set 1 #

Total comments: 16

Patch Set 2 : memcache ns and mock enqueue task #

Patch Set 3 : clone arg #

Patch Set 4 : cancel_by_transaction_id #

Patch Set 5 : nits #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+304 lines, -50 lines) Patch
M appengine/swarming/handlers_bot_test.py View 6 chunks +6 lines, -6 lines 0 comments Download
M appengine/swarming/handlers_endpoints.py View 1 2 3 4 7 chunks +99 lines, -9 lines 0 comments Download
M appengine/swarming/handlers_endpoints_test.py View 1 2 3 17 chunks +172 lines, -27 lines 0 comments Download
M appengine/swarming/server/task_pack.py View 1 chunk +2 lines, -2 lines 0 comments Download
M appengine/swarming/server/task_request.py View 1 2 1 chunk +4 lines, -3 lines 0 comments Download
M appengine/swarming/server/task_scheduler.py View 1 3 chunks +10 lines, -2 lines 0 comments Download
M appengine/swarming/swarming_rpcs.py View 1 2 3 2 chunks +10 lines, -0 lines 1 comment Download
M appengine/swarming/test_env_handlers.py View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 21 (12 generated)
nodir
PTAL
3 years, 7 months ago (2017-05-01 21:34:33 UTC) #3
M-A Ruel
https://codereview.chromium.org/2856733002/diff/1/appengine/swarming/handlers_endpoints.py File appengine/swarming/handlers_endpoints.py (right): https://codereview.chromium.org/2856733002/diff/1/appengine/swarming/handlers_endpoints.py#newcode84 appengine/swarming/handlers_endpoints.py:84: task_id = memcache.get(transaction_id_to_memcache_key(transaction_id)) use a namespace, it's simpler. Then ...
3 years, 7 months ago (2017-05-03 01:33:21 UTC) #6
nodir
https://codereview.chromium.org/2856733002/diff/1/appengine/swarming/handlers_endpoints.py File appengine/swarming/handlers_endpoints.py (right): https://codereview.chromium.org/2856733002/diff/1/appengine/swarming/handlers_endpoints.py#newcode84 appengine/swarming/handlers_endpoints.py:84: task_id = memcache.get(transaction_id_to_memcache_key(transaction_id)) On 2017/05/03 01:33:20, M-A Ruel wrote: ...
3 years, 7 months ago (2017-05-05 18:11:38 UTC) #9
M-A Ruel
https://codereview.chromium.org/2856733002/diff/1/appengine/swarming/handlers_endpoints.py File appengine/swarming/handlers_endpoints.py (right): https://codereview.chromium.org/2856733002/diff/1/appengine/swarming/handlers_endpoints.py#newcode355 appengine/swarming/handlers_endpoints.py:355: 'only one of task_id or transaction_id must be specified') ...
3 years, 7 months ago (2017-05-05 18:15:33 UTC) #10
nodir
https://codereview.chromium.org/2856733002/diff/1/appengine/swarming/handlers_endpoints.py File appengine/swarming/handlers_endpoints.py (right): https://codereview.chromium.org/2856733002/diff/1/appengine/swarming/handlers_endpoints.py#newcode355 appengine/swarming/handlers_endpoints.py:355: 'only one of task_id or transaction_id must be specified') ...
3 years, 7 months ago (2017-05-05 18:41:37 UTC) #15
nodir
ping
3 years, 7 months ago (2017-05-09 15:05:42 UTC) #18
M-A Ruel
https://codereview.chromium.org/2856733002/diff/80001/appengine/swarming/swarming_rpcs.py File appengine/swarming/swarming_rpcs.py (right): https://codereview.chromium.org/2856733002/diff/80001/appengine/swarming/swarming_rpcs.py#newcode242 appengine/swarming/swarming_rpcs.py:242: # If two NewTaskRequests use the same transaction ID, ...
3 years, 7 months ago (2017-05-10 13:41:25 UTC) #19
nodir
On 2017/05/10 13:41:25, M-A Ruel wrote: > https://codereview.chromium.org/2856733002/diff/80001/appengine/swarming/swarming_rpcs.py > File appengine/swarming/swarming_rpcs.py (right): > > https://codereview.chromium.org/2856733002/diff/80001/appengine/swarming/swarming_rpcs.py#newcode242 ...
3 years, 7 months ago (2017-05-10 14:01:04 UTC) #20
M-A Ruel
3 years, 7 months ago (2017-05-10 15:48:50 UTC) #21
On 2017/05/10 14:01:04, nodir wrote:
> On 2017/05/10 13:41:25, M-A Ruel wrote:
> >
>
https://codereview.chromium.org/2856733002/diff/80001/appengine/swarming/swar...
> > File appengine/swarming/swarming_rpcs.py (right):
> > 
> >
>
https://codereview.chromium.org/2856733002/diff/80001/appengine/swarming/swar...
> > appengine/swarming/swarming_rpcs.py:242: # If two NewTaskRequests use the
same
> > transaction ID, requests must have all
> > Hey, thinking about it, what about if all attributes are the same, why not
use
> > the hash of the request minus created_ts and using
(expiration_ts-created_ts)
> as
> > a relative value? Then no need for an arbitrary ID.
> > 
> > Right now we use TaskRequest.properties_hash for task result deduping but
what
> > I'm thinking about is TaskRequest.request_hash for task request deduping.
This
> > would be much more generic and would be transparent to the user.
> > 
> > Give me a day to think about it. I think it'd work quite fine, as all the
task
> > retry logic we have already use a different task name.
> 
> It would work for LUCI because tasks have different buildbucket ids,  but I
> worry that for others swarming may start deduping non-idempotent tasks that
look
> the same

We can filter this on a short window, 1~5 minutes.

Powered by Google App Engine
This is Rietveld 408576698