From 6146e4a993c07713aca486fd58f29decfea94aa6 Mon Sep 17 00:00:00 2001 From: Googler Date: Thu, 30 Mar 2023 02:14:44 -0700 Subject: [PATCH] [Skymeld] Include the underlying IOException's details if it happens while planting the SymlinkForest. The current behavior only prints out a generic "ERROR: Failed to prepare the symlink forest" without any further details of what's wrong. PiperOrigin-RevId: 520577912 Change-Id: I7c124f601ad876b5ac4efd94a538ffee97b3ef0c --- .../devtools/build/lib/buildtool/ExecutionTool.java | 11 +++++++++-- .../build/lib/skyframe/IncrementalPackageRoots.java | 2 +- .../devtools/build/lib/skyframe/SkyframeExecutor.java | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java index 65c7f2a9e8dff0..11531a65b80ace 100644 --- a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java +++ b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java @@ -258,7 +258,12 @@ public void prepareForExecution(UUID buildId, Stopwatch executionTimer) SkyframeExecutor skyframeExecutor = env.getSkyframeExecutor(); try (SilentCloseable c = Profiler.instance().profile("preparingExecroot")) { - Root singleSourceRoot = Iterables.getOnlyElement(env.getPackageLocator().getPathEntries()); + boolean shouldSymlinksBePlanted = + skyframeExecutor.getForcedSingleSourceRootIfNoExecrootSymlinkCreation() == null; + Root singleSourceRoot = + shouldSymlinksBePlanted + ? Iterables.getOnlyElement(env.getPackageLocator().getPathEntries()) + : skyframeExecutor.getForcedSingleSourceRootIfNoExecrootSymlinkCreation(); IncrementalPackageRoots incrementalPackageRoots = IncrementalPackageRoots.createAndRegisterToEventBus( getExecRoot(), @@ -267,7 +272,9 @@ public void prepareForExecution(UUID buildId, Stopwatch executionTimer) env.getDirectories().getProductName() + "-", request.getOptions(BuildLanguageOptions.class).experimentalSiblingRepositoryLayout, runtime.getWorkspace().doesAllowExternalRepositories()); - incrementalPackageRoots.eagerlyPlantSymlinksToSingleSourceRoot(); + if (shouldSymlinksBePlanted) { + incrementalPackageRoots.eagerlyPlantSymlinksToSingleSourceRoot(); + } // We don't plant the symlinks via the subscribers of this ExecRootPreparedEvent, but rather // via IncrementalPackageRoots. diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/IncrementalPackageRoots.java b/src/main/java/com/google/devtools/build/lib/skyframe/IncrementalPackageRoots.java index 6badfa0d5b2787..569fd2f3760f10 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/IncrementalPackageRoots.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/IncrementalPackageRoots.java @@ -181,7 +181,7 @@ private static void throwAbruptExitException(IOException e) throws AbruptExitExc throw new AbruptExitException( DetailedExitCode.of( FailureDetail.newBuilder() - .setMessage("Failed to prepare the symlink forest") + .setMessage("Failed to prepare the symlink forest: " + e) .setSymlinkForest( FailureDetails.SymlinkForest.newBuilder() .setCode(FailureDetails.SymlinkForest.Code.CREATION_FAILED)) diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java index f5c7e1cc645a85..2d59f404428e87 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java @@ -998,7 +998,7 @@ protected boolean shouldDeleteActionNodesWhenDroppingAnalysis() { */ // TODO(wyv): To be safe, fail early if we're in a multi-repo setup but this is not being tracked. @Nullable - protected Root getForcedSingleSourceRootIfNoExecrootSymlinkCreation() { + public Root getForcedSingleSourceRootIfNoExecrootSymlinkCreation() { return null; }