Sonar-Job in gitlab pipeline randomly crashes with java.nio.file.NoSuchFileException

  • SonarQube: 10.5.1,
  • Scanner: 11.0
  • Plugin: sonar branch plugin
  • SonarQube deployed: Helm

Similar to this issues, my pipelines crashes on

Caused by: java.nio.file.NoSuchFileException: /tmp/platform/.git/.probe-f6b29551-6f66-4234-ad27-a007a01883b1

What I tried

  • I have tried adding .git folder to sonar.exclusions using wild card patterns such as .git/**, **/.git/** but these issues occur randomly.

  • I have also tried to give concrete paths instead of sonar.source=. but the issue still remains

These are the detailed logs

08:42:20.269 DEBUG Using pattern 'coverage-reports/*coverage-*.xml' to find reports

08:42:20.380 DEBUG delta [ns] since modification FileSnapshot failed to detect

count, failures, racy limit [ns], delta min [ns], delta max [ns], delta avg [ns], delta stddev [ns]

1701, 34, 8000, 3301136.0, 6625969.0, 4875906.88235294, 1011366.1593544546

08:42:20.380 DEBUG FileStoreAttributes[fsTimestampResolution=3 µs, minimalRacyInterval=6,625 µs]

08:42:20.383 DEBUG register org.eclipse.jgit.internal.storage.file.LockFile$$Lambda$1920/0x00007ff2746d4dd0@469e35d2 with shutdown hook

08:42:20.383 DEBUG unregister org.eclipse.jgit.internal.storage.file.LockFile$$Lambda$1920/0x00007ff2746d4dd0@469e35d2 from shutdown hook

08:42:20.385 DEBUG unregister org.eclipse.jgit.internal.storage.file.LockFile$$Lambda$1920/0x00007ff2746d4dd0@469e35d2 from shutdown hook

08:42:20.451 INFO EXECUTION FAILURE

08:42:20.451 INFO Total time: 7.592s

08:42:20.451 ERROR Error during SonarScanner CLI execution

java.io.UncheckedIOException: java.nio.file.NoSuchFileException: /tmp/platform/.git/.probe-3a00a6a9-f78b-41ef-8e2e-b9dfb739b21f

at java.base/java.nio.file.FileTreeIterator.fetchNextIfNeeded(Unknown Source)

at java.base/java.nio.file.FileTreeIterator.hasNext(Unknown Source)

at java.base/java.util.Iterator.forEachRemaining(Unknown Source)

at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source)

at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)

at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)

at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)

at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)

at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)

at org.sonarsource.analyzer.commons.FileProvider.getMatchingFiles(FileProvider.java:45)

at org.sonar.plugins.python.PythonReportSensor.getReports(PythonReportSensor.java:73)

at org.sonar.plugins.python.coverage.PythonCoverageSensor.getCoverageReports(PythonCoverageSensor.java:89)

at org.sonar.plugins.python.coverage.PythonCoverageSensor.execute(PythonCoverageSensor.java:77)

at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)

at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:88)

at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:61)

at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:79)

at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:61)

at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)

at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)

at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)

at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:204)

at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:200)

at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:173)

at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)

at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)

at org.sonar.scanner.bootstrap.SpringScannerContainer.doAfterStart(SpringScannerContainer.java:351)

at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)

at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)

at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:138)

at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:226)

at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:205)

at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:71)

at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:65)

at org.sonarsource.scanner.lib.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:41)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.base/java.lang.reflect.Method.invoke(Unknown Source)

at org.sonarsource.scanner.lib.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:62)

at jdk.proxy3/jdk.proxy3.$Proxy2.execute(Unknown Source)

at org.sonarsource.scanner.lib.InProcessScannerEngineFacade.doAnalyze(InProcessScannerEngineFacade.java:39)

at org.sonarsource.scanner.lib.ScannerEngineFacade.analyze(ScannerEngineFacade.java:61)

at org.sonarsource.scanner.cli.Main.analyze(Main.java:77)

at org.sonarsource.scanner.cli.Main.main(Main.java:63)

Caused by: java.nio.file.NoSuchFileException: /tmp/platform/.git/.probe-3a00a6a9-f78b-41ef-8e2e-b9dfb739b21f

at java.base/sun.nio.fs.UnixException.translateToIOException(Unknown Source)

at java.base/sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source)

at java.base/sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source)

at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(Unknown Source)

at java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(Unknown Source)

at java.base/sun.nio.fs.LinuxFileSystemProvider.readAttributes(Unknown Source)

at java.base/java.nio.file.Files.readAttributes(Unknown Source)

at java.base/java.nio.file.FileTreeWalker.getAttributes(Unknown Source)

at java.base/java.nio.file.FileTreeWalker.visit(Unknown Source)

at java.base/java.nio.file.FileTreeWalker.next(Unknown Source)

... 45 common frames omitted

Hello @Nischal,

Thank you for reporting this. After having a look, I believe the root cause is that the analyzer does not fail gracefully when encountering an exception during the look-up of coverage files. I created SONARPY-2120 to fix this.

In the meantime, have you configured any kind of coverage report importing through the sonar.python.coverage.reportPaths key? A workaround could be to specify this property to ensure that it doesn’t search in the .git folder by specifying the concrete path here (by the way, note that the sources property is sonar.sources rather than sonar.source - but this would not solve your issue).

Cheers,
Guillaume

Dear @Guillaume_Dequenne
Thanks for replying.

  1. For coverage we have skipped the test coverage altogether using sonar.coverage.exclusions=**/*. I am not using sonar.python.coverage.reportPaths in sonar-project.properties file.
  2. It is indeed sonar.sources=.

Hello @Nischal,

I believe that, if you’re not using sonar.python.coverage.reportPaths, a default value is being used, as we can see in your logs:

08:42:20.269 DEBUG Using pattern 'coverage-reports/*coverage-*.xml' to find reports

Maybe setting it to something specific could be a workaround for your problem (sonar.coverage.exclusions does not limit where the analyzer looks for a report, only which files will be considered in the report). In any case, I think the root cause of your problem remains the ticket I mentioned, which we’ll hopefully fix soon (although I can’t commit to a specific timeframe).