bazel: cc_test coverage fails when fetching from remote cache
Description of the bug:
Running coverage on a cc_test randomly fails with the following error:
I/O exception during sandboxed execution: Input is a directory: bazel-out/k8-fastbuild/testlogs/<path_to_the_test_dir>/_coverage
Afaik, the condition under which the bug happens might be:
- A coverage test passes and gets cached remotely.
- The artifacts of the last action (which collects coverage data) get evicted from the remote cache.
- The coverage test is triggered (in another job), and only the action is run, as everything else is already in the cache.
- The action tries to fetch the input artifacts, which contains a TreeArtifact (the _coverage directory).
- An exception is thrown https://github.com/bazelbuild/bazel/blob/7.0.0/src/main/java/com/google/devtools/build/lib/exec/SingleBuildFileCache.java#L78, probably because Bazel doesn’t allow inputs to be directories.
Which category does this issue belong to?
Remote Execution
What’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
- Use disk_cache instead of remote_cache to easily manipulate the cache. (add --disk_cache=<path_to_local_cache> to the command line).
- Run a cc_test:
bazel coverage <test> --disk_cache=<cache> --remote_upload_local_results=true --execution_log_json_file=<file_name>. - Open the json file, find the action that has
"commandArgs": ["external/bazel_tools/tools/test/collect_coverage.sh"], - Find the hash of the action output (near the end of the action object).
- Delete the file corresponding to the hash value in the cache directory.
- Rerun the test.
- The test fails with the error:
I/O exception during sandboxed execution: Input is a directory: bazel-out/k8-fastbuild/testlogs/<path_to_the_test_dir>/_coverage.
Which operating system are you running Bazel on?
Ubuntu 20.04.6 LTS
What is the output of bazel info release?
release 7.0.0
If bazel info release returns development version or (@non-git), tell us how you built Bazel.
No response
What’s the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?
No response
Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
Probably it happens after this commit 1267631fee7523ea3ae572c9b8c9c1fc9c8c9452, when it tries to fetch metadata of a TreeArtifact (the _coverage directory).
Have you found anything relevant by searching the web?
No.
Any other information, logs, or outputs that you want to share?
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 31 (18 by maintainers)
Commits related to this issue
- Alternative fix for #20556 — committed to tjgq/bazel by tjgq 3 years ago
I think the idea is that 7.0.1 should be out sometime next week the latest (don’t take this as a promise until @meteorcloudy confirms)
@bazel-io fork 7.0.1
@bazel-io flag