Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.3.0] Enrich local BEP upload errors with file path and digest possible. #18481

Merged
merged 1 commit into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ private Single<List<PathMetadata>> queryRemoteCache(
return toSingle(() -> remoteCache.findMissingDigests(context, digestsToQuery), executor)
.onErrorResumeNext(
error -> {
reporterUploadError(error);
reportUploadError(error, null, null);
// Assuming all digests are missing if failed to query
return Single.just(ImmutableSet.copyOf(digestsToQuery));
})
Expand All @@ -267,13 +267,19 @@ private Single<List<PathMetadata>> queryRemoteCache(
});
}

private void reporterUploadError(Throwable error) {
private void reportUploadError(Throwable error, Path path, Digest digest) {
if (error instanceof CancellationException) {
return;
}

String errorMessage =
"Uploading BEP referenced local files: " + grpcAwareErrorMessage(error, verboseFailures);
String errorMessage = "Uploading BEP referenced local file";
if (path != null) {
errorMessage += " " + path;
}
if (digest != null) {
errorMessage += " " + digest;
}
errorMessage += ": " + grpcAwareErrorMessage(error, verboseFailures);

reporter.handle(Event.warn(errorMessage));
}
Expand All @@ -298,11 +304,11 @@ private Single<List<PathMetadata>> uploadLocalFiles(
path.isDirectory(),
// set remote to true so the PathConverter will use bytestream://
// scheme to convert the URI for this file
/*remote=*/ true,
/* remote= */ true,
path.isOmitted()))
.onErrorResumeNext(
error -> {
reporterUploadError(error);
reportUploadError(error, path.getPath(), path.getDigest());
return Single.just(path);
});
})
Expand All @@ -329,7 +335,7 @@ private Single<PathConverter> upload(Set<Path> files) {
try {
return readPathMetadata(file);
} catch (IOException e) {
reporterUploadError(e);
reportUploadError(e, file, null);
return new PathMetadata(
file,
/* digest= */ null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public void onCompleted() {

assertThat(eventHandler.getEvents()).isNotEmpty();
assertThat(eventHandler.getEvents().get(0).getMessage())
.contains("Uploading BEP referenced local files: ");
.contains("Uploading BEP referenced local file /file");

artifactUploader.release();

Expand Down