Remote coverage does not have a configuration
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 75
Description
### Description of the bug:
I am trying to get coverage to work in our RBE cluster.
Collecting the coverage works locally with:
```console
$ bazel coverage -s --combined_report=lcov //python: trivial_test
SUBCOMMAND: # (unknown) [action 'Coverage report generation', configuration: system]
(cd XXX/execroot/federation_example && \
exec env - \
JAVA_RUNFILES=bazel-out/darwin-opt-exec-2B5CBBC6/bin/external/remote_coverage_tools/Main.runfiles \
PYTHON_RUNFILES=bazel-out/darwin-opt-exec-2B5CBBC6/bin/external/remote_coverage_tools/Main.runfiles \
bazel-out/darwin-opt-exec-2B5CBBC6/bin/external/remote_coverage_tools/Main '--reports_file=bazel-out/_coverage/lcov_files.tmp' '--output_file=bazel-out/_coverage/_coverage_report.dat')
# Configuration: system
INFO: LCOV coverage report is located at /private/var/tmp/_bazel_steve/988dbe4dd5ee602e299c1f37c1a3d6b2/execroot/federation_example/bazel-out/_coverage/_coverage_report.dat
and execpath is bazel-out/_coverage/_coverage_report.dat
INFO: From Coverage report generation:
Oct 10, 2023 12:09:19 PM com.google.devtools.coverageoutputgenerator.Main getTracefiles
INFO: Found 1 tracefiles.
Oct 10, 2023 12:09:19 PM com.google.devtools.coverageoutputgenerator.Main parseFilesSequentially
INFO: Parsing file bazel-out/darwin-fastbuild/testlogs/python/trivial_test/coverage.dat
Oct 10, 2023 12:09:19 PM com.google.devtools.coverageoutputgenerator.Main getGcovInfoFiles
INFO: No gcov info file found.
Oct 10, 2023 12:09:19 PM com.google.devtools.coverageoutputgenerator.Main getGcovJsonInfoFiles
INFO: No gcov json file found.
Oct 10, 2023 12:09:19 PM com.google.devtools.coverageoutputgenerator.Main getProfdataFileOrNull
INFO: No .profdata file found.
Target //python: trivial_test up-to-date:
bazel-bin/python/trivial_test
INFO: Elapsed time: 45.101s, Critical Path: 4.29s
INFO: 15 processes: 4 disk cache hit, 10 internal, 1 darwin-sandbox.
INFO: Build completed successfully, 15 total actions
//python: trivial_test (cached) PASSED in 4.0s
XXX/execroot/federation_example/bazel-out/darwin-fastbuild/testlogs/python/trivial_test/coverage.dat
Executed 0 out of 1 test: 1 test passes.
```
Running the same with RBE:
```console
$ bazel-with-our-rbe coverage --combined_report=lcov --experimental_fetch_all_coverage_outputs --experimental_split_coverage_postprocessing -s //python:trivial_test
....
SUBCOMMAND: # (unknown) [action 'Coverage report generation', configuration: system]
(cd XXX/execroot/federation_example && \
exec env - \
JAVA_RUNFILES=bazel-out/k8-opt-exec-BAC2A3E1/bin/external/remote_coverage_tools/Main.runfiles \
PYTHON_RUNFILES=bazel-out/k8-opt-exec-BAC2A3E1/bin/external/remote_coverage_tools/Main.runfiles \
bazel-out/k8-opt-exec-BAC2A3E1/bin/external/remote_coverage_tools/Main '--reports_file=bazel-out/_coverage/lcov_files.tmp' '--output_file=bazel-out/_coverage/_coverage_report.dat')
# Configuration: system
ERROR: : Coverage report generation failed: (Exit 34): FAILED_PRECONDITION: No workers exist for instance name prefix "" platform {}
java.io.IOException: io.grpc.StatusRuntimeException: FAILED_PRECONDITION: No workers exist for instance name prefix "" platform {}
at com.google.devtools.build.lib.remote.GrpcRemoteExecutor.executeRemotely(GrpcRemoteExecutor.java:244)
at com.google.devtools.build.lib.remote.RemoteExecutionService.executeRemotely(RemoteExecutionService.java:1499)
at com.google.devtools.build.lib.remote.RemoteSpawnRunner.lambda$exec$2(RemoteSpawnRunner.java:269)
at com.google.devtools.build.lib.remote.Retrier.execute(Retrier.java:245)
at com.google.devtools.build.lib.remote.RemoteRetrier.execute(RemoteRetrier.java:127)
at com.google.devtools.build.lib.remote.RemoteRetrier.execute(RemoteRetrier.java:116)
at com.google.devtools.build.lib.remote.RemoteSpawnRunner.exec(RemoteSpawnRunner.java:244)
at com.google.devtools.build.lib.exec.SpawnRunner.execAsync(SpawnRunner.java:301)
at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:152)
at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:112)
at com.google.devtools.build.lib.exec.SpawnStrategyResolver.exec(SpawnStrategyResolver.java:46)
at com.google.devtools.build.lib.bazel.coverage.CoverageReportActionBuilder$CoverageReportAction.execute(CoverageReportActionBuilder.java:152)
at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$5.execute(SkyframeActionExecutor.java:961)
at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.continueAction(SkyframeActionExecutor.java:1128)
at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.run(SkyframeActionExecutor.java:1086)
at com.google.devtools.build.lib.skyframe.ActionExecutionState.runStateMachine(ActionExecutionState.java:160)
at com.google.devtools.build.lib.skyframe.ActionExecutionState.getResultOrDependOnFuture(ActionExecutionState.java:93)
at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.executeAction(SkyframeActionExecutor.java:519)
at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.checkCacheAndExecuteIfNeeded(ActionExecutionFunction.java:827)
at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.computeInternal(ActionExecutionFunction.java:323)
at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.compute(ActionExecutionFunction.java:161)
at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:562)
at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:365)
at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: io.grpc.StatusRuntimeException: FAILED_PRECONDITION: No workers exist for instance name prefix "" platform {}
at io.grpc.Status.asRuntimeException(Status.java:535)
at io.grpc.stub.ClientCalls$BlockingResponseStream.hasNext(ClientCalls.java:648)
at com.google.devtools.build.lib.remote.GrpcRemoteExecutor.lambda$executeRemotely$2(GrpcRemoteExecutor.java:178)
at com.google.devtools.build.lib.remote.Retrier.execute(Retrier.java:245)
at com.google.devtools.build.lib.remote.RemoteRetrier.execute(RemoteRetrier.java:127)
at com.google.devtools.build.lib.remote.RemoteRetrier.execute(RemoteRetrier.java:116)
at com.google.devtools.build.lib.remote.GrpcRemoteExecutor.lambda$executeRemotely$3(GrpcRemoteExecutor.java:149)
at com.google.devtools.build.lib.remote.util.Utils.refreshIfUnauthenticated(Utils.java:523)
at com.google.devtools.build.lib.remote.GrpcRemoteExecutor.executeRemotely(GrpcRemoteExecutor.java:147)
... 28 more
Target //python:trivial_test up-to-date:
bazel-bin/python/trivial_test
INFO: Elapsed time: 1.548s, Critical Path: 0.67s
INFO: 3 processes: 1 remote cache hit, 2 internal.
FAILED: Build did NOT complete successfully
//python: trivial_test (cached) PASSED in 1.0s
XXX/bazel-out/k8-fastbuild/testlogs/python/trivial_test/coverage.dat
Executed 0 out of 1 test: 1 test passes.
All tests passed but there were other errors during the build.
```
I am puzzled by the `Configuration: system` bit. IIUC the [CoverageReportAction](https://github.com/bazelbuild/bazel/blob/9a7b1f7808c59abebb91a79f05aedefeddedfbba/src/main/java/com/google/devtools/build/lib/bazel/coverage/CoverageReportActionBuilder.java#L113C5-L113C25) should spawn a BasicSpawn with a configuration. In our RBE implementation this means we need to manually specify the exec properties using `--remote_default_platform_properties` to get this to work remotely. We would like to avoid using `remote_default_platform_properties` as a workaround given this probably creates situations where if a spawn does not have a platform set, it will run them incorrectly.
Is this the expected behavior or is there an oversight is setting the configuration for the `CoverageReportAction`? It feels like either the BasicSpawn needs to inherit a platform (e.g. from the host platform or the default exec platform), or there needs to be a way to specify the coverage action's flag (e.g. a --coverage_platform flat or similar)?
### Which category does this issue belong to?
_No response_
### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
```python
# python/trivial.py
def foo():
return 1
```
```python
# python/trivial_test.py
import unittest
from python import trivial
class TrivialTest(unittest.TestCase):
def test_trivial(self):
self.assertEqual(1, trivial.foo())
```
Use rules_python and a wrapper for unittest to get XML outputs.
### Which operating system are you running Bazel on?
macOS 12.6.3
### What is the output of `bazel info release`?
release 6.3.2
### 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.
_No response_
### Have you found anything relevant by searching the web?
I looked for `coverage configuration` to no avail.
### Any other information, logs, or outputs that you want to share?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.