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: dm/appengine/mutate/timeout_execution.go

Issue 2347973003: Refactor distributor API so that methods always get the Quest_Desc too. (Closed)
Patch Set: Created 4 years, 3 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 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package mutate 5 package mutate
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "time" 9 "time"
10 10
11 "golang.org/x/net/context" 11 "golang.org/x/net/context"
12 12
13 "github.com/luci/gae/filter/txnBuf"
13 "github.com/luci/gae/service/datastore" 14 "github.com/luci/gae/service/datastore"
14 "github.com/luci/luci-go/common/clock" 15 "github.com/luci/luci-go/common/clock"
16 "github.com/luci/luci-go/common/errors"
15 "github.com/luci/luci-go/common/logging" 17 "github.com/luci/luci-go/common/logging"
16 dm "github.com/luci/luci-go/dm/api/service/v1" 18 dm "github.com/luci/luci-go/dm/api/service/v1"
17 "github.com/luci/luci-go/dm/appengine/distributor" 19 "github.com/luci/luci-go/dm/appengine/distributor"
18 "github.com/luci/luci-go/dm/appengine/model" 20 "github.com/luci/luci-go/dm/appengine/model"
19 "github.com/luci/luci-go/tumble" 21 "github.com/luci/luci-go/tumble"
20 ) 22 )
21 23
22 // TimeoutExecution is a named mutation which triggers on a delay. If the 24 // TimeoutExecution is a named mutation which triggers on a delay. If the
23 // execution is in the noted state when the trigger hits, this sets the 25 // execution is in the noted state when the trigger hits, this sets the
24 // Execution to have an AbnormalFinish status of TIMED_OUT. 26 // Execution to have an AbnormalFinish status of TIMED_OUT.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // TODO(iannucci): make this set the REJECTED state if we loaded the config, 80 // TODO(iannucci): make this set the REJECTED state if we loaded the config,
79 // but the distributor no longer exists. 81 // but the distributor no longer exists.
80 if err != nil { 82 if err != nil {
81 logging.Fields{ 83 logging.Fields{
82 logging.ErrorKey: err, 84 logging.ErrorKey: err,
83 "cfgName": e.DistributorConfigName, 85 "cfgName": e.DistributorConfigName,
84 }.Errorf(c, "Could not MakeDistributor") 86 }.Errorf(c, "Could not MakeDistributor")
85 return 87 return
86 } 88 }
87 var realRslt *dm.Result 89 var realRslt *dm.Result
88 » » realRslt, err = dist.GetStatus(distributor.Token(e.DistributorTo ken)) 90 » » q := model.QuestFromID(t.For.Quest)
91 » » if err = txnBuf.GetNoTxn(c).Get(q); err != nil {
92 » » » err = errors.Annotate(err).Reason("loading quest").Err()
93 » » » return
94 » » }
95 » » realRslt, err = dist.GetStatus(&q.Desc, distributor.Token(e.Dist ributorToken))
89 if (err != nil || realRslt == nil) && t.TimeoutAttempt < maxTime outAttempts { 96 if (err != nil || realRslt == nil) && t.TimeoutAttempt < maxTime outAttempts {
90 logging.Fields{ 97 logging.Fields{
91 logging.ErrorKey: err, 98 logging.ErrorKey: err,
92 "task_result": realRslt, 99 "task_result": realRslt,
93 "timeout_attempt": t.TimeoutAttempt, 100 "timeout_attempt": t.TimeoutAttempt,
94 }.Infof(c, "GetStatus failed/nop'd while timing out STOP PING execution") 101 }.Infof(c, "GetStatus failed/nop'd while timing out STOP PING execution")
95 // TODO(riannucci): do randomized exponential backoff in stead of constant 102 // TODO(riannucci): do randomized exponential backoff in stead of constant
96 // backoff? Kinda don't really want to spend more than 1 .5m waiting 103 // backoff? Kinda don't really want to spend more than 1 .5m waiting
97 // anyway, and the actual GetStatus call does local retr ies already, so 104 // anyway, and the actual GetStatus call does local retr ies already, so
98 // hopefully this is fine. If this is wrong, the distrib utor should adjust 105 // hopefully this is fine. If this is wrong, the distrib utor should adjust
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 return tumble.CancelNamedMutations(c, key, "timeout") 149 return tumble.CancelNamedMutations(c, key, "timeout")
143 } 150 }
144 return tumble.PutNamedMutations(c, key, map[string]tumble.Mutation{ 151 return tumble.PutNamedMutations(c, key, map[string]tumble.Mutation{
145 "timeout": &TimeoutExecution{eid, e.State, 0, clock.Now(c).UTC() .Add(howLong)}, 152 "timeout": &TimeoutExecution{eid, e.State, 0, clock.Now(c).UTC() .Add(howLong)},
146 }) 153 })
147 } 154 }
148 155
149 func init() { 156 func init() {
150 tumble.Register((*TimeoutExecution)(nil)) 157 tumble.Register((*TimeoutExecution)(nil))
151 } 158 }
OLDNEW
« dm/appengine/distributor/fake/fake.go ('K') | « dm/appengine/mutate/schedule_execution.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698