Skip to content

Commit

Permalink
[Remote Cache] Don't delete tree artifacts on failure
Browse files Browse the repository at this point in the history
    Previously if a remote cache request failed, bazel would cleanup all
    directories that were marked as outputs for the action. These
    directories wouldn't end up being re-created by bazel, and could lead to
    failures if the actions didn't create the directories themselves. With
    this patch bazel deletes all output files, and the child directories of
    all output directories.

    Fixes bazelbuild/bazel#6260

    Closes #6851.

    PiperOrigin-RevId: 224781649
  • Loading branch information
Luca Di Grazia committed Sep 4, 2022
1 parent 33b115e commit 0f11aa1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,12 @@ public void onSuccess(Void result) {

@Override
public void onFailure(Throwable t) {
outerF.setException(t);
try {
out.close();
} catch (IOException e) {
// Intentionally left empty. The download already failed, so we can ignore
// the error on close().
} finally {
outerF.setException(t);
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.google.devtools.build.lib.actions.ExecException;
import com.google.devtools.build.lib.clock.JavaClock;
import com.google.devtools.build.lib.remote.AbstractRemoteActionCache.UploadManifest;
import com.google.devtools.build.lib.remote.TreeNodeRepository.TreeNode;
import com.google.devtools.build.lib.remote.util.DigestUtil;
import com.google.devtools.build.lib.remote.util.DigestUtil.ActionKey;
import com.google.devtools.build.lib.remote.util.Utils;
Expand Down Expand Up @@ -718,6 +719,13 @@ protected <T> T getFromFuture(ListenableFuture<T> f) throws IOException, Interru
return Utils.getFromFuture(f);
}

@Override
public void ensureInputsPresent(
TreeNodeRepository repository, Path execRoot, TreeNode root, Action action, Command command)
throws IOException, InterruptedException {
throw new UnsupportedOperationException();
}

@Nullable
@Override
ActionResult getCachedActionResult(ActionKey actionKey)
Expand Down

0 comments on commit 0f11aa1

Please sign in to comment.