From 8da805c03ceee9166b8d1ecd4b97d4081e679718 Mon Sep 17 00:00:00 2001 From: Emil Kattainen Date: Mon, 2 Jan 2023 16:24:15 +0200 Subject: [PATCH] Upload all logs in BEP even with minimal upload When using --experimental_remote_build_event_upload=minimal, build action logs won't get uploaded. These logs are still very useful as when a build action fails, one would need to inspect them to figure out what has gone wrong. Forcing uploading stdout and stderr with this change. --- .../ByteStreamBuildEventArtifactUploader.java | 8 +++--- .../remote_build_event_uploader_test.sh | 25 ++++++++++++++++++- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploader.java b/src/main/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploader.java index 2593a677a967d5..0e1cee0e11ba34 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploader.java +++ b/src/main/java/com/google/devtools/build/lib/remote/ByteStreamBuildEventArtifactUploader.java @@ -63,6 +63,7 @@ class ByteStreamBuildEventArtifactUploader extends AbstractReferenceCounted implements BuildEventArtifactUploader { private static final Pattern TEST_LOG_PATTERN = Pattern.compile(".*/bazel-out/[^/]*/testlogs/.*"); + private static final Pattern BUILD_LOG_PATTERN = Pattern.compile(".*/bazel-out/_tmp/actions/std(err|out)-.*"); private final Executor executor; private final ExtendedEventHandler reporter; @@ -216,14 +217,15 @@ private boolean shouldUpload(PathMetadata path) { path.getDigest() != null && !path.isRemote() && !path.isDirectory() && !path.isOmitted(); if (remoteBuildEventUploadMode == RemoteBuildEventUploadMode.MINIMAL) { - result = result && (isTestLog(path) || isProfile(path)); + result = result && (isLog(path) || isProfile(path)); } return result; } - private boolean isTestLog(PathMetadata path) { - return TEST_LOG_PATTERN.matcher(path.getPath().getPathString()).matches(); + private boolean isLog(PathMetadata path) { + return TEST_LOG_PATTERN.matcher(path.getPath().getPathString()).matches() || + BUILD_LOG_PATTERN.matcher(path.getPath().getPathString()).matches(); } private boolean isProfile(PathMetadata path) { diff --git a/src/test/shell/bazel/remote/remote_build_event_uploader_test.sh b/src/test/shell/bazel/remote/remote_build_event_uploader_test.sh index 2611ce305f434e..4ab18ea3ec6645 100755 --- a/src/test/shell/bazel/remote/remote_build_event_uploader_test.sh +++ b/src/test/shell/bazel/remote/remote_build_event_uploader_test.sh @@ -269,6 +269,29 @@ EOF expect_log "command.profile.gz.*bytestream://" || fail "should upload profile data" } +function test_upload_minimal_upload_buildlogs() { + mkdir -p a + cat > a/BUILD <& $TEST_log || true + + cat bep.json > $TEST_log + expect_log "stdout.*bytestream://" || fail "should upload stdout" + expect_log "stderr.*bytestream://" || fail "should upload stderr" + expect_log "command.profile.gz.*bytestream://" || fail "should upload profile data" +} + function test_upload_minimal_upload_profile() { mkdir -p a cat > a/BUILD <