OLD | NEW |
1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 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 deps | 5 package deps |
6 | 6 |
7 import ( | 7 import ( |
8 "fmt" | 8 "fmt" |
9 | 9 |
10 "github.com/luci/luci-go/appengine/cmd/dm/mutate" | 10 "github.com/luci/luci-go/appengine/cmd/dm/mutate" |
11 "github.com/luci/luci-go/common/api/dm/service/v1" | 11 "github.com/luci/luci-go/common/api/dm/service/v1" |
12 "github.com/luci/luci-go/common/api/template" | 12 "github.com/luci/luci-go/common/api/template" |
13 "github.com/luci/luci-go/common/grpcutil" | 13 "github.com/luci/luci-go/common/grpcutil" |
14 "github.com/luci/luci-go/common/logging" | 14 "github.com/luci/luci-go/common/logging" |
15 google_pb "github.com/luci/luci-go/common/proto/google" | 15 google_pb "github.com/luci/luci-go/common/proto/google" |
16 "golang.org/x/net/context" | 16 "golang.org/x/net/context" |
17 "google.golang.org/grpc/codes" | 17 "google.golang.org/grpc/codes" |
18 ) | 18 ) |
19 | 19 |
20 const resultMaxLength = 256 * 1024 | 20 const resultMaxLength = 256 * 1024 |
21 | 21 |
22 func (d *deps) FinishAttempt(c context.Context, req *dm.FinishAttemptReq) (_ *go
ogle_pb.Empty, err error) { | 22 func (d *deps) FinishAttempt(c context.Context, req *dm.FinishAttemptReq) (_ *go
ogle_pb.Empty, err error) { |
| 23 logging.Fields{"execution": req.Auth.Id}.Infof(c, "finishing") |
23 if len(req.JsonResult) > resultMaxLength { | 24 if len(req.JsonResult) > resultMaxLength { |
24 return nil, fmt.Errorf("result payload is too large: %d > %d", | 25 return nil, fmt.Errorf("result payload is too large: %d > %d", |
25 len(req.JsonResult), resultMaxLength) | 26 len(req.JsonResult), resultMaxLength) |
26 } | 27 } |
27 | 28 |
28 req.JsonResult, err = template.NormalizeJSON(req.JsonResult, true) | 29 req.JsonResult, err = template.NormalizeJSON(req.JsonResult, true) |
29 if err != nil { | 30 if err != nil { |
30 » » logging.WithError(err).Infof(c, "failed to normalized json") | 31 » » logging.WithError(err).Infof(c, "failed to normalize json") |
31 » » return nil, grpcutil.Errf(codes.InvalidArgument, "resuld json ha
d normalization error: %s", err.Error()) | 32 » » return nil, grpcutil.Errf(codes.InvalidArgument, "result json ha
d normalization error: %s", err.Error()) |
32 } | 33 } |
33 | 34 |
34 » return nil, tumbleNow(c, &mutate.FinishAttempt{ | 35 » return &google_pb.Empty{}, tumbleNow(c, &mutate.FinishAttempt{ |
35 Auth: req.Auth, | 36 Auth: req.Auth, |
36 Result: req.JsonResult, | 37 Result: req.JsonResult, |
37 ResultExpiration: req.Expiration.Time(), | 38 ResultExpiration: req.Expiration.Time(), |
38 }) | 39 }) |
39 } | 40 } |
OLD | NEW |