Skip to content

refactor: replace errutil.MultiError with errors.Join - #762

Closed
MannXo wants to merge 1 commit into
uber:masterfrom
MannXo:refactor/761-errors-join
Closed

MannXo wants to merge 1 commit into
uber:masterfrom
MannXo:refactor/761-errors-join

Conversation

@MannXo

@MannXo MannXo commented Nov 19, 2026

Copy link
Copy Markdown

Summary

Replaces every use of errutil.MultiError and errutil.Join with the standard library's errors.Join, and marks both errutil identifiers as deprecated.

Changes

  • origin/blobclient/cluster_client.go (OverwriteMetaInfo, Owners, Poll), origin/blobserver/server.go (applyToReplicas), tracker/originstore/store.go (GetOrigins) and tracker/trackerserver/announce.go (getPeerHandout) now call errors.Join(errs...) instead of errutil.Join(errs).
  • tools/bin/puller/pull.go collects layer errors in a plain []error and joins them with errors.Join when formatting the failure.
  • utils/errutil: MultiError and Join get a Deprecated: notice pointing at errors.Join. Nothing in the repo uses them any more.
  • New test TestClusterClientOwnersAllFailWrapsErrors checks that when every origin fails, Owners returns an error that errors.Is matches against each origin's error. MultiError has no Unwrap, so this fails on master and passes here.

The nil behaviour is unchanged at every call site. Each errs slice is built with append from nil, so it is nil exactly when it is empty, and errors.Join returns nil in that case just like errutil.Join did.

One visible difference is the separator. MultiError joined messages with ", ", while errors.Join uses a newline. So messages such as all origins unavailable: ... and no peers available: ... now list one origin error per line. DownloadBlob in the same file already builds its error with errors.Join, so this makes the messages consistent.

Testing

$ go build ./...
$ go test -race -count=1 -cover ./utils/errutil ./tools/bin/puller ./tracker/originstore ./tracker/trackerserver ./origin/blobserver ./origin/blobclient
ok  	github.com/uber/kraken/utils/errutil	1.163s	coverage: 100.0% of statements
	github.com/uber/kraken/tools/bin/puller		coverage: 0.0% of statements
ok  	github.com/uber/kraken/tracker/originstore	1.196s	coverage: 84.3% of statements
ok  	github.com/uber/kraken/tracker/trackerserver	1.202s	coverage: 73.8% of statements
ok  	github.com/uber/kraken/origin/blobserver	3.393s	coverage: 75.9% of statements
ok  	github.com/uber/kraken/origin/blobclient	1.376s	coverage: 95.1% of statements
$ golangci-lint run ./utils/errutil/... ./tools/bin/puller/... ./tracker/originstore/... ./tracker/trackerserver/... ./origin/blobserver/... ./origin/blobclient/...
0 issues.

The same packages also pass with --tags unit as make unit-test runs them. With the cluster_client.go change reverted, the new test fails with Target error should be in err chain: expected: "origin 1 failed".

Notes for reviewers

  • I deprecated the package rather than deleting it, since the issue asks for deprecation and utils/errutil is importable from outside the repo. If you would rather remove it now, it is a two-file deletion and I can add it here.
  • fix(build-index): retry manifest downloads that fail with a network error #759 touches the same Poll return line (%s to %w) and adds Unwrap to MultiError. 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 in build-index/tagtype/docker_resolver_test.go calls errutil.Join, which the deprecation notice here would make staticcheck flag (SA1019), so I would switch that call to errors.Join in the same rebase.
  • The format verbs are left as they were (%s stays %s). Switching the wrapping sites to %w would change what errors.Is sees through them and felt out of scope.

Fixes #761

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
@cla-assistant

cla-assistant Bot commented Nov 19, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@thijmv thijmv closed this Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate errutil.MultiError in favour of errors.join

2 participants