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

Issue 2951393002: [errors] de-specialize Transient in favor of Tags. (Closed)

Created:
3 years, 6 months ago by iannucci
Modified:
3 years, 5 months ago
Reviewers:
dnj, Vadim Sh., nodir
CC:
chromium-reviews, infra-reviews+luci-go_chromium.org, maruel+w_chromium.org, tandrii+luci-go_chromium.org
Target Ref:
refs/heads/master
Project:
luci-go
Visibility:
Public.

Description

[errors] de-specialize Transient in favor of Tags. Previously 'transience' was a hard-coded attribute of the errors package. This change adds 'tags' as a way to put attributes (potentially with some data) onto an error as it goes up the stack. This removes multiple symbols from the errors package (the stack context stuff is now an implementation detail, tags are better than ExtractData). The 'transience' bit has now moved to the 'common/retry/transient' package. Marking an error as transient is now `err = transient.Tag.Apply(err)`, or `errors.Annotate(err).Tag(transient.Tag).Err()` (as part of another batch of annotations). API Review in a Nutshell: // for simple 'boolean' tags, where presence is the only important piece of // information. var FatalTag = errors.BoolTag{errors.NewTagKey("this is a fatal error!")} func (...) error { return FatalTag.Apply(err) } func (...) { if FatalTag.In(err) { os.Exit(-1) } } // tags may also have associated typesafe values type Severity int type severityTagType struct {Key errors.TagKey} func (t severityTagType) With(s Severity) errors.TagValue { return errors.MkTagValue(t.Key, s) } func (t severityTagType) In(err error) (s Severity, ok bool) { d, ok := errors.TagValueIn(t.Key, err) if ok { s = d.(Severity) } return } var SeverityTag = severityTagType{errors.NewTagKey("holds a Severity value")} func (...) error { return SeverityTag.With(Severity(10)).Apply(err) } func (...) { if s, hasSeverity := SeverityTag.In(err); hasSeverity { if s.(Severity) > 9000 { fmt.Println("it's pretty severe") } } } BUG= Review-Url: https://codereview.chromium.org/2951393002 Committed: https://github.com/luci/luci-go/commit/585415ced4abef0b0ceff6c495690df98db83abb

Patch Set 1 #

Patch Set 2 : add missing file #

Patch Set 3 : most stuff working #

Patch Set 4 : fix prpc test #

Patch Set 5 : copyright #

Total comments: 35

Patch Set 6 : refactor and make typesafe #

Patch Set 7 : remove top level MakeTagValue symbol #

Patch Set 8 : rebase #

Total comments: 1

Patch Set 9 : more refactor #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+879 lines, -583 lines) Patch
M appengine/datastorecache/cache.go View 1 2 3 4 5 3 chunks +3 lines, -2 lines 0 comments Download
M appengine/gaeauth/client/client.go View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M appengine/gaeauth/server/cache.go View 1 2 3 4 5 3 chunks +5 lines, -5 lines 0 comments Download
M appengine/gaeauth/server/internal/authdbimpl/authdb.go View 1 2 3 4 5 6 chunks +6 lines, -5 lines 0 comments Download
M appengine/gaeauth/server/internal/authdbimpl/handlers.go View 1 2 3 4 5 2 chunks +2 lines, -1 line 0 comments Download
M appengine/gaeauth/server/oauth.go View 1 2 3 4 5 3 chunks +4 lines, -2 lines 0 comments Download
M appengine/gaeauth/server/session.go View 1 2 3 4 5 4 chunks +4 lines, -4 lines 0 comments Download
M appengine/gaesecrets/gaesecrets.go View 1 2 3 4 5 4 chunks +5 lines, -5 lines 0 comments Download
M appengine/gaesettings/gaesettings.go View 1 2 3 4 5 4 chunks +4 lines, -4 lines 0 comments Download
M buildbucket/client/cmd/buildbucket/client.go View 1 2 3 4 5 3 chunks +4 lines, -5 lines 0 comments Download
M cipd/client/cipd/client.go View 1 2 3 4 5 2 chunks +9 lines, -8 lines 0 comments Download
M cipd/client/cli/main.go View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M common/auth/auth.go View 1 2 3 4 5 6 7 3 chunks +3 lines, -2 lines 0 comments Download
M common/auth/auth_test.go View 1 2 3 4 5 3 chunks +2 lines, -2 lines 0 comments Download
M common/auth/internal/common.go View 1 2 3 4 5 2 chunks +2 lines, -1 line 0 comments Download
M common/auth/internal/disk_cache.go View 1 2 3 4 5 3 chunks +3 lines, -3 lines 0 comments Download
M common/auth/internal/iam.go View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M common/auth/internal/luci_ctx.go View 1 2 3 4 5 2 chunks +4 lines, -4 lines 0 comments Download
M common/auth/internal/luci_ctx_test.go View 1 2 3 4 5 4 chunks +4 lines, -4 lines 0 comments Download
M common/auth/internal/service.go View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M common/auth/internal/user.go View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M common/auth/localauth/server.go View 1 2 3 4 5 3 chunks +5 lines, -5 lines 0 comments Download
M common/auth/localauth/server_test.go View 1 2 3 4 5 2 chunks +2 lines, -1 line 0 comments Download
M common/config/impl/remote/remote.go View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M common/config/validation/validation.go View 1 2 3 4 5 6 7 8 2 chunks +28 lines, -2 lines 0 comments Download
M common/config/validation/validation_test.go View 1 2 3 4 5 6 7 8 2 chunks +7 lines, -3 lines 0 comments Download
M common/errors/annotate.go View 1 2 3 4 5 6 7 8 18 chunks +114 lines, -103 lines 0 comments Download
M common/errors/multierror.go View 1 2 3 4 5 1 chunk +4 lines, -5 lines 0 comments Download
A common/errors/tags.go View 1 2 3 4 5 6 7 8 1 chunk +160 lines, -0 lines 4 comments Download
A common/errors/tags_test.go View 1 2 3 4 5 6 7 8 1 chunk +134 lines, -0 lines 0 comments Download
D common/errors/transient.go View 1 chunk +0 lines, -65 lines 0 comments Download
D common/errors/transient_test.go View 1 chunk +0 lines, -49 lines 0 comments Download
M common/errors/walk_test.go View 2 chunks +0 lines, -2 lines 0 comments Download
M common/gcloud/googleoauth/info.go View 1 2 3 4 5 4 chunks +4 lines, -3 lines 0 comments Download
M common/gcloud/gs/gs.go View 1 2 3 4 5 5 chunks +5 lines, -4 lines 0 comments Download
M common/gcloud/gs/writer.go View 1 2 3 4 5 3 chunks +4 lines, -4 lines 0 comments Download
M common/lhttp/client.go View 1 2 3 4 5 4 chunks +9 lines, -7 lines 0 comments Download
M common/retry/transient.go View 1 2 3 4 5 1 chunk +0 lines, -40 lines 0 comments Download
A common/retry/transient/transient.go View 1 2 3 4 5 6 7 8 1 chunk +68 lines, -0 lines 0 comments Download
D common/retry/wrap.go View 1 2 3 4 5 1 chunk +0 lines, -17 lines 0 comments Download
M common/testing/assertions/grpc.go View 1 2 3 2 chunks +2 lines, -1 line 0 comments Download
M dm/appengine/deps/auth.go View 1 2 3 4 5 3 chunks +3 lines, -2 lines 0 comments Download
M dm/appengine/deps/ensure_graph_data.go View 1 5 chunks +5 lines, -5 lines 0 comments Download
M dm/appengine/deps/service.go View 1 1 chunk +1 line, -1 line 0 comments Download
A dm/appengine/deps/util.go View 1 1 chunk +15 lines, -0 lines 0 comments Download
M dm/appengine/mutate/add_deps.go View 3 chunks +5 lines, -2 lines 0 comments Download
M dm/appengine/mutate/finish_attempt.go View 2 chunks +3 lines, -1 line 0 comments Download
M dm/appengine/mutate/schedule_execution.go View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M dm/appengine/mutate/schedule_execution_test.go View 1 2 3 4 5 2 chunks +2 lines, -1 line 0 comments Download
M grpc/grpcutil/errors.go View 1 2 3 4 5 6 7 8 2 chunks +21 lines, -12 lines 2 comments Download
M grpc/prpc/client.go View 1 2 3 4 5 5 chunks +6 lines, -4 lines 0 comments Download
M grpc/prpc/client_test.go View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M grpc/prpc/encoding.go View 1 chunk +1 line, -1 line 0 comments Download
M grpc/prpc/server.go View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M logdog/appengine/coordinator/endpoints/logs/get.go View 1 2 3 4 5 3 chunks +3 lines, -2 lines 0 comments Download
M logdog/client/butler/output/pubsub/pubsubOutput.go View 1 2 3 4 5 3 chunks +3 lines, -2 lines 0 comments Download
M logdog/common/archive/archive.go View 2 chunks +0 lines, -5 lines 0 comments Download
M logdog/common/storage/bigtable/bigtable.go View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M logdog/common/storage/bigtable/initialize.go View 1 2 3 4 5 2 chunks +3 lines, -2 lines 0 comments Download
M logdog/server/archivist/archivist.go View 1 2 3 4 5 3 chunks +3 lines, -2 lines 0 comments Download
M logdog/server/archivist/archivist_test.go View 1 2 3 4 5 7 chunks +7 lines, -6 lines 0 comments Download
M logdog/server/cmd/logdog_archivist/main.go View 1 2 3 4 5 2 chunks +2 lines, -1 line 0 comments Download
M logdog/server/cmd/logdog_collector/main.go View 1 2 3 4 5 3 chunks +3 lines, -2 lines 0 comments Download
M logdog/server/collector/collector_test.go View 1 2 3 4 5 15 chunks +16 lines, -15 lines 0 comments Download
M logdog/server/collector/coordinator/cache.go View 1 2 3 4 5 3 chunks +3 lines, -3 lines 0 comments Download
M logdog/server/collector/coordinator/cache_test.go View 1 2 3 4 5 3 chunks +4 lines, -3 lines 0 comments Download
M logdog/server/retryServicesClient/client.go View 1 2 3 4 5 2 chunks +2 lines, -1 line 0 comments Download
M milo/build_source/buildbucket/builder.go View 1 2 3 4 5 2 chunks +3 lines, -2 lines 0 comments Download
M scheduler/appengine/engine/engine.go View 1 2 3 4 5 26 chunks +27 lines, -27 lines 0 comments Download
M scheduler/appengine/engine/engine_test.go View 1 2 3 4 5 4 chunks +5 lines, -4 lines 0 comments Download
M scheduler/appengine/engine/pubsub.go View 1 2 3 4 5 4 chunks +4 lines, -3 lines 0 comments Download
M scheduler/appengine/frontend/handler.go View 1 2 3 4 5 3 chunks +3 lines, -3 lines 0 comments Download
M scheduler/appengine/task/buildbucket/buildbucket.go View 1 2 3 4 5 3 chunks +3 lines, -2 lines 0 comments Download
M scheduler/appengine/task/swarming/swarming.go View 1 2 3 4 5 3 chunks +3 lines, -2 lines 0 comments Download
M scheduler/appengine/task/utils/apiclient.go View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M server/auth/actor.go View 1 2 3 4 5 2 chunks +2 lines, -3 lines 0 comments Download
M server/auth/auth.go View 1 2 3 4 5 3 chunks +3 lines, -2 lines 0 comments Download
M server/auth/auth_test.go View 1 2 3 4 5 2 chunks +2 lines, -1 line 0 comments Download
M server/auth/delegation.go View 1 2 3 4 5 3 chunks +3 lines, -3 lines 0 comments Download
M server/auth/delegation/checker.go View 1 2 3 4 5 3 chunks +3 lines, -2 lines 0 comments Download
M server/auth/internal/fetch.go View 1 2 3 4 5 3 chunks +3 lines, -3 lines 0 comments Download
M server/auth/openid/cookie.go View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M server/auth/openid/method.go View 1 2 3 4 5 2 chunks +2 lines, -1 line 0 comments Download
M server/auth/xsrf/xsrf.go View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M server/settings/admin/handlers.go View 1 2 3 4 5 3 chunks +3 lines, -2 lines 0 comments Download
M server/settings/settings.go View 1 2 3 4 5 2 chunks +2 lines, -1 line 0 comments Download
M tokenserver/appengine/impl/certchecker/certchecker.go View 1 2 3 4 5 3 chunks +3 lines, -3 lines 0 comments Download
M tokenserver/appengine/impl/certconfig/ca.go View 1 2 3 4 5 4 chunks +4 lines, -4 lines 0 comments Download
M tokenserver/appengine/impl/certconfig/crl.go View 1 2 3 4 5 3 chunks +3 lines, -2 lines 0 comments Download
M tokenserver/appengine/impl/certconfig/rpc_fetch_crl.go View 1 2 3 4 5 6 chunks +8 lines, -6 lines 0 comments Download
M tokenserver/appengine/impl/delegation/rpc_mint_delegation_token.go View 1 2 3 4 5 4 chunks +4 lines, -4 lines 0 comments Download
M tokenserver/appengine/impl/machinetoken/machinetoken.go View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M tokenserver/appengine/impl/machinetoken/rpc_inspect_machine_token.go View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M tokenserver/appengine/impl/machinetoken/rpc_mint_machine_token.go View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M tokenserver/appengine/impl/utils/bqlog/bqlog.go View 1 2 3 4 5 4 chunks +4 lines, -3 lines 0 comments Download
M tokenserver/appengine/impl/utils/bqlog/bqlog_test.go View 1 2 3 4 5 2 chunks +2 lines, -1 line 0 comments Download
M tokenserver/appengine/impl/utils/policy/entities.go View 1 2 3 4 5 4 chunks +4 lines, -4 lines 0 comments Download
M tokenserver/appengine/impl/utils/revocation/id.go View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M tokenserver/appengine/impl/utils/tokensigning/inspector.go View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M tokenserver/appengine/impl/utils/tokensigning/signer.go View 1 2 3 4 5 3 chunks +3 lines, -3 lines 0 comments Download
M tokenserver/auth/machine/auth_method.go View 1 2 3 4 5 4 chunks +5 lines, -4 lines 0 comments Download
M tokenserver/client/tokenclient.go View 1 2 3 4 5 3 chunks +8 lines, -10 lines 0 comments Download
M tumble/process.go View 1 2 3 4 5 2 chunks +2 lines, -1 line 0 comments Download
M tumble/service.go View 1 2 3 4 5 2 chunks +2 lines, -1 line 0 comments Download

Dependent Patchsets:

Messages

Total messages: 48 (35 generated)
iannucci
PTAL https://codereview.chromium.org/2951393002/diff/80001/common/errors/tags.go File common/errors/tags.go (right): https://codereview.chromium.org/2951393002/diff/80001/common/errors/tags.go#newcode1 common/errors/tags.go:1: // Copyright 2017 The LUCI Authors. All rights ...
3 years, 6 months ago (2017-06-24 00:01:12 UTC) #9
dnj
Nice work. I like it, but I have a lot of thoughts and a few ...
3 years, 6 months ago (2017-06-24 14:53:55 UTC) #12
iannucci
PTAnL https://codereview.chromium.org/2951393002/diff/80001/appengine/datastorecache/cache.go File appengine/datastorecache/cache.go (right): https://codereview.chromium.org/2951393002/diff/80001/appengine/datastorecache/cache.go#newcode339 appengine/datastorecache/cache.go:339: return retry.Tag.Apply(err) On 2017/06/24 14:53:54, dnj wrote: > ...
3 years, 6 months ago (2017-06-24 20:16:10 UTC) #15
dnj
I think the custom struct is the right direction. I thought about this for a ...
3 years, 5 months ago (2017-06-26 15:50:52 UTC) #28
iannucci
ptal, this is a hybrid approach. I renamed ValueIn to just `In`. It makes sense ...
3 years, 5 months ago (2017-06-27 01:28:27 UTC) #34
iannucci
On 2017/06/27 01:28:27, iannucci wrote: > ptal, this is a hybrid approach. > > I ...
3 years, 5 months ago (2017-06-27 02:12:17 UTC) #35
dnj
This lgtm. Thanks for iterating! Just a few comments. None are blockers, more just thoughts. ...
3 years, 5 months ago (2017-06-27 03:57:03 UTC) #36
iannucci
https://codereview.chromium.org/2951393002/diff/160001/common/errors/tags.go File common/errors/tags.go (right): https://codereview.chromium.org/2951393002/diff/160001/common/errors/tags.go#newcode34 common/errors/tags.go:34: TagValueGenerator interface { On 2017/06/27 03:57:03, dnj wrote: > ...
3 years, 5 months ago (2017-06-27 18:14:28 UTC) #37
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2951393002/160001
3 years, 5 months ago (2017-06-27 20:58:24 UTC) #40
commit-bot: I haz the power
Try jobs failed on following builders: Luci-go Presubmit on luci.infra.try (JOB_FAILED, https://luci-milo.appspot.com/swarming/task/37042aa87d5eb610)
3 years, 5 months ago (2017-06-27 21:31:19 UTC) #42
iannucci
Yay now our builds fail nondeterministically due to npm stuff :'(
3 years, 5 months ago (2017-06-27 21:42:46 UTC) #43
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2951393002/160001
3 years, 5 months ago (2017-06-28 17:55:48 UTC) #45
commit-bot: I haz the power
3 years, 5 months ago (2017-06-28 18:13:21 UTC) #48
Message was sent while issue was closed.
Committed patchset #9 (id:160001) as
https://github.com/luci/luci-go/commit/585415ced4abef0b0ceff6c495690df98db83abb

Powered by Google App Engine
This is Rietveld 408576698