Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analysis Docker container can't reach Sonar container for scanning via sonar-scanner #3602

Open
phanlezz opened this issue Apr 30, 2024 · 0 comments
Labels
bug Only issues that describe bugs. docker pr-analysis Issues that touch the analysis pr(oject). priority:high Set by PO

Comments

@phanlezz
Copy link
Collaborator

Bug

Expected Behavior

GIVEN our docker-compose setup

WHEN using the analysis container to analyse code with sonar-scanner

THEN it should be able to communicate with the sonar instance provided by our docker-compose on localhost:9000

Actual Behavior

It can't reach the destination.

Screenshots

nonroot-docker-user@82fd9dc17b9d:/$ /usr/local/bin/sonar-scanner
INFO: Scanner configuration file: /usr/local/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarScanner 4.7.0.2747
INFO: Java 11.0.14.1 Eclipse Adoptium (64-bit)
INFO: Linux 6.5.0-28-generic amd64
INFO: User cache: /home/nonroot-docker-user/.sonar/cache
ERROR: SonarQube server [http://localhost:9000] can not be reached
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 0.219s
INFO: Final Memory: 3M/54M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarScanner analysis
	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:85)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:74)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:70)
	at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:185)
	at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:123)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:73)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.IllegalStateException: Fail to get bootstrap index from server
	at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:42)
	at org.sonarsource.scanner.api.internal.JarDownloader.getScannerEngineFiles(JarDownloader.java:58)
	at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:53)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:76)
	... 7 more
Caused by: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:9000

Steps to Reproduce the Problem

  1. docker compose pull && docker compose up --detach
  2. docker run -it codecharta/codecharta-analysis bash
  3. /usr/local/bin/sonar-scanner

Specifications

  • CodeCharta Version: unreleased (and probably previous versions)
  • OS: tested on ubuntu 22

Due to a syntax error in our analysis Dockerfile the current release does not include the sonar-scanner iirc.
This is fixed in #3571
To reproduce this error without the released Dockerfile you can (as soon at this PR is merged on main)
$ docker compose build && docker compose up --detach

@phanlezz phanlezz added bug Only issues that describe bugs. pr-analysis Issues that touch the analysis pr(oject). docker labels Apr 30, 2024
@phanlezz phanlezz changed the title Tech: Analysis Docker container can't reach Sonar container for scanning via sonar-scanner Analysis Docker container can't reach Sonar container for scanning via sonar-scanner Apr 30, 2024
@ChristianHuehn ChristianHuehn added the priority:high Set by PO label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Only issues that describe bugs. docker pr-analysis Issues that touch the analysis pr(oject). priority:high Set by PO
Projects
None yet
Development

No branches or pull requests

2 participants