Repository navigation
Conversation
Go 1.20 added errors.Join, which also supports errors.Is and errors.As on the joined errors. Switch every caller of errutil.Join and errutil.MultiError to it and mark both as deprecated. Fixes uber#761
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces every use of
errutil.MultiErroranderrutil.Joinwith the standard library'serrors.Join, and marks botherrutilidentifiers as deprecated.Changes
origin/blobclient/cluster_client.go(OverwriteMetaInfo,Owners,Poll),origin/blobserver/server.go(applyToReplicas),tracker/originstore/store.go(GetOrigins) andtracker/trackerserver/announce.go(getPeerHandout) now callerrors.Join(errs...)instead oferrutil.Join(errs).tools/bin/puller/pull.gocollects layer errors in a plain[]errorand joins them witherrors.Joinwhen formatting the failure.utils/errutil:MultiErrorandJoinget aDeprecated:notice pointing aterrors.Join. Nothing in the repo uses them any more.TestClusterClientOwnersAllFailWrapsErrorschecks that when every origin fails,Ownersreturns an error thaterrors.Ismatches against each origin's error.MultiErrorhas noUnwrap, so this fails onmasterand passes here.The
nilbehaviour is unchanged at every call site. Eacherrsslice is built withappendfromnil, so it isnilexactly when it is empty, anderrors.Joinreturnsnilin that case just likeerrutil.Joindid.One visible difference is the separator.
MultiErrorjoined messages with", ", whileerrors.Joinuses a newline. So messages such asall origins unavailable: ...andno peers available: ...now list one origin error per line.DownloadBlobin the same file already builds its error witherrors.Join, so this makes the messages consistent.Testing
The same packages also pass with
--tags unitasmake unit-testruns them. With thecluster_client.gochange reverted, the new test fails withTarget error should be in err chain: expected: "origin 1 failed".Notes for reviewers
utils/errutilis importable from outside the repo. If you would rather remove it now, it is a two-file deletion and I can add it here.Pollreturn line (%sto%w) and addsUnwraptoMultiError. Whichever merges second needs a one-line rebase, which I will do if this one is second. If fix(build-index): retry manifest downloads that fail with a network error #759 lands first, its new test inbuild-index/tagtype/docker_resolver_test.gocallserrutil.Join, which the deprecation notice here would make staticcheck flag (SA1019), so I would switch that call toerrors.Joinin the same rebase.%sstays%s). Switching the wrapping sites to%wwould change whaterrors.Issees through them and felt out of scope.Fixes #761