Sonar analysis using gradle with scanner plugin fails with 503/502 error

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)

SonarQube: * Community Edition Version 9.5 (build 56709)
Scanner: sonar-scanner-cli:4.6.2.2472
Gradle: 7.3
Java: 17.0.2

  • what are you trying to achieve
    Doing a sonar analysis using gradle with sonar scanner plugin on one of our git project based on Java.

  • what have you tried so far to achieve this

Sonar sever used here is provisioned on a kubernetes based POD using the helm project (GitHub - SonarSource/helm-chart-sonarqube)

Step followed:

  1. Setup a new sonar server instance on k8s
  2. Do a new sonar analysis against our Java project using gradle cli command

Error Encountering:
Getting below error during sonar analysis,

09:05:03.576 DEBUG: Detection of duplications for /media/django/sdc1/groovy_workspace/pmc-test/pmc-ui-ftc/src/main/java/com/ibm/pmc/selenium/pageobject/enhanced/RestorefromUSBPage.java
09:05:03.576 DEBUG: Detection of duplications for /media/django/sdc1/groovy_workspace/pmc-test/pmc-rest-sdk-devtest/src/main/java/com/ibm/pmc/rest/sdk/devtest/facade/SharedStoragePoolFacade.java
09:05:03.576 INFO: CPD Executor CPD calculation finished (done) | time=15694ms
09:05:03.659 DEBUG: SCM revision ID '2d4f1b6c498fb69894d8748e89e8540eeb193d23'
09:05:07.905 INFO: Analysis report generated in 3794ms, dir size=40.9 MB
09:05:18.733 INFO: Analysis report compressed in 10656ms, zip size=9.5 MB
09:05:18.734 INFO: Analysis report generated in /pmc-test/.scannerwork/scanner-report
09:05:18.734 DEBUG: Upload report
09:05:21.180 DEBUG: POST 200 http://xxx.ibm.com/devsonarqube/api/ce/submit?projectKey=com.ibm.pvm%3Apmc-test&projectName=pmc-test | time=2249ms
09:05:21.547 INFO: Analysis report uploaded in 2812ms
09:05:21.549 DEBUG: Report metadata written to /pmc-test/.scannerwork/report-task.txt
09:05:21.549 INFO: ------------- Check Quality Gate status
09:05:21.599 INFO: Waiting for the analysis report to be processed (max 900s)
09:05:21.682 DEBUG: GET 200 http://xxx.ibm.com/devsonarqube/api/ce/task?id=AYJe4Z-W5yr_OQLZjvgO | time=83ms
09:05:27.029 DEBUG: GET 200 http://xxx.ibm.com/devsonarqube/api/ce/task?id=AYJe4Z-W5yr_OQLZjvgO | time=127ms
09:05:32.044 DEBUG: GET 200 http://xxx.ibm.com/devsonarqube/api/ce/task?id=AYJe4Z-W5yr_OQLZjvgO | time=15ms
09:05:37.060 DEBUG: GET 200 http://xxx.ibm.com/devsonarqube/api/ce/task?id=AYJe4Z-W5yr_OQLZjvgO | time=15ms
09:05:42.138 DEBUG: GET 200 http://xxx.ibm.com/devsonarqube/api/ce/task?id=AYJe4Z-W5yr_OQLZjvgO | time=78ms
09:05:47.233 DEBUG: GET 200 http://xxx.ibm.com/devsonarqube/api/ce/task?id=AYJe4Z-W5yr_OQLZjvgO | time=95ms
09:05:52.237 DEBUG: GET 503 http://xxx.ibm.com/devsonarqube/api/ce/task?id=AYJe4Z-W5yr_OQLZjvgO | time=3ms
09:05:52.299 INFO: ------------------------------------------------------------------------
09:05:52.299 INFO: EXECUTION FAILURE
09:05:52.299 INFO: ------------------------------------------------------------------------
09:05:52.299 INFO: Total time: 14:18.094s
09:05:52.489 INFO: Final Memory: 124M/3769M
09:05:52.489 INFO: ------------------------------------------------------------------------
09:05:52.489 ERROR: Error during SonarScanner execution
Failed to get CE Task status - HTTP code 503: <html>
<head><title>503 Service Temporarily Unavailable</title></head>
<body>
<center><h1>503 Service Temporarily Unavailable

Additional Logs:
From access.log

10.244.3.1 - - [02/Aug/2022:14:03:20 +0000] "GET /devsonarqube/api/system/liveness HTTP/1.1" 204 - "-" "kube-probe/1.23" "AYJe0lweWIgcg/bfAAB1"
10.244.3.35 - - [02/Aug/2022:14:03:20 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 76 "-" "Wget" "AYJe0lweWIgcg/bfAAB2"
10.244.3.1 - - [02/Aug/2022:14:03:50 +0000] "GET /devsonarqube/api/system/liveness HTTP/1.1" 204 - "-" "kube-probe/1.23" "AYJe0lweWIgcg/bfAAB3"
10.244.3.35 - - [02/Aug/2022:14:03:50 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 76 "-" "Wget" "AYJe0lweWIgcg/bfAAB4"
10.244.3.1 - - [02/Aug/2022:14:04:20 +0000] "GET /devsonarqube/api/system/liveness HTTP/1.1" 204 - "-" "kube-probe/1.23" "AYJe0lweWIgcg/bfAAB5"
10.244.3.35 - - [02/Aug/2022:14:04:20 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 76 "-" "Wget" "AYJe0lweWIgcg/bfAAB6"
10.244.3.1 - - [02/Aug/2022:14:04:50 +0000] "GET /devsonarqube/api/system/liveness HTTP/1.1" 204 - "-" "kube-probe/1.23" "AYJe0lweWIgcg/bfAAB7"
10.244.3.35 - - [02/Aug/2022:14:04:50 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 76 "-" "Wget" "AYJe0lweWIgcg/bfAAB8"
10.244.3.1 - - [02/Aug/2022:14:05:20 +0000] "GET /devsonarqube/api/system/liveness HTTP/1.1" 204 - "-" "kube-probe/1.23" "AYJe0lweWIgcg/bfAAB9"
10.244.3.35 - - [02/Aug/2022:14:05:20 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 76 "-" "Wget" "AYJe0lweWIgcg/bfAAB+"
10.244.3.1 - - [02/Aug/2022:14:05:50 +0000] "GET /devsonarqube/api/system/liveness HTTP/1.1" 204 - "-" "kube-probe/1.23" "AYJe0lweWIgcg/bfAAB/"
10.244.3.35 - - [02/Aug/2022:14:05:50 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 76 "-" "Wget" "AYJe0lweWIgcg/bfAACA"
10.244.3.1 - - [02/Aug/2022:14:06:20 +0000] "GET /devsonarqube/api/system/liveness HTTP/1.1" 204 - "-" "kube-probe/1.23" "AYJe0lweWIgcg/bfAACB"
10.244.3.35 - - [02/Aug/2022:14:06:20 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 76 "-" "Wget" "AYJe0lweWIgcg/bfAACC"
10.244.3.1 - - [02/Aug/2022:14:06:50 +0000] "GET /devsonarqube/api/system/liveness HTTP/1.1" 204 - "-" "kube-probe/1.23" "AYJe0lweWIgcg/bfAACD"
10.244.3.35 - - [02/Aug/2022:14:06:50 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 76 "-" "Wget" "AYJe0lweWIgcg/bfAACE"
10.244.3.1 - - [02/Aug/2022:14:07:01 +0000] "POST /devsonarqube/api/ce/submit?projectKey=com.ibm.pvm%3Apmc-test&projectName=pmc-test HTTP/1.1" 200 44 "-" "ScannerCLI/4.6.2.2472" "AYJe0lweWIgcg/bfAACF"
10.244.3.1 - - [02/Aug/2022:14:07:02 +0000] "GET /devsonarqube/api/ce/task?id=AYJe4Z-W5yr_OQLZjvgO HTTP/1.1" 200 126 "-" "ScannerCLI/4.6.2.2472" "AYJe0lweWIgcg/bfAACG"
10.244.3.1 - - [02/Aug/2022:14:07:07 +0000] "GET /devsonarqube/api/ce/task?id=AYJe4Z-W5yr_OQLZjvgO HTTP/1.1" 200 156 "-" "ScannerCLI/4.6.2.2472" "AYJe0lweWIgcg/bfAACH"
10.244.3.1 - - [02/Aug/2022:14:07:12 +0000] "GET /devsonarqube/api/ce/task?id=AYJe4Z-W5yr_OQLZjvgO HTTP/1.1" 200 156 "-" "ScannerCLI/4.6.2.2472" "AYJe0lweWIgcg/bfAACI"
10.244.3.1 - - [02/Aug/2022:14:07:17 +0000] "GET /devsonarqube/api/ce/task?id=AYJe4Z-W5yr_OQLZjvgO HTTP/1.1" 200 156 "-" "ScannerCLI/4.6.2.2472" "AYJe0lweWIgcg/bfAACJ"
10.244.3.1 - - [02/Aug/2022:14:07:20 +0000] "GET /devsonarqube/api/system/liveness HTTP/1.1" 204 - "-" "kube-probe/1.23" "AYJe0lweWIgcg/bfAACK"
10.244.3.35 - - [02/Aug/2022:14:07:20 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 76 "-" "Wget" "AYJe0lweWIgcg/bfAACL"
10.244.3.1 - - [02/Aug/2022:14:07:22 +0000] "GET /devsonarqube/api/ce/task?id=AYJe4Z-W5yr_OQLZjvgO HTTP/1.1" 200 157 "-" "ScannerCLI/4.6.2.2472" "AYJe0lweWIgcg/bfAACM"
10.244.3.1 - - [02/Aug/2022:14:07:27 +0000] "GET /devsonarqube/api/ce/task?id=AYJe4Z-W5yr_OQLZjvgO HTTP/1.1" 200 157 "-" "ScannerCLI/4.6.2.2472" "AYJe0lweWIgcg/bfAACN"
10.244.3.1 - - [02/Aug/2022:14:08:19 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 82 "-" "kube-probe/1.23" "-"
10.244.3.1 - - [02/Aug/2022:14:08:20 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 82 "-" "kube-probe/1.23" "-"
10.244.3.1 - - [02/Aug/2022:14:08:50 +0000] "GET /devsonarqube/api/system/liveness HTTP/1.1" 204 - "-" "kube-probe/1.23" "AYJe40vLcPXxgssFAAAA"
10.244.3.35 - - [02/Aug/2022:14:08:50 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 76 "-" "Wget" "AYJe40vLcPXxgssFAAAB"
10.244.3.1 - - [02/Aug/2022:14:09:20 +0000] "GET /devsonarqube/api/system/liveness HTTP/1.1" 204 - "-" "kube-probe/1.23" "AYJe40vLcPXxgssFAAAC"
10.244.3.35 - - [02/Aug/2022:14:09:20 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 76 "-" "Wget" "AYJe40vLcPXxgssFAAAD"
10.244.3.1 - - [02/Aug/2022:14:09:50 +0000] "GET /devsonarqube/api/system/liveness HTTP/1.1" 204 - "-" "kube-probe/1.23" "AYJe40vLcPXxgssFAAAE"
10.244.3.35 - - [02/Aug/2022:14:09:50 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 76 "-" "Wget" "AYJe40vLcPXxgssFAAAF"
10.244.3.1 - - [02/Aug/2022:14:10:20 +0000] "GET /devsonarqube/api/system/liveness HTTP/1.1" 204 - "-" "kube-probe/1.23" "AYJe40vLcPXxgssFAAAG"
10.244.3.35 - - [02/Aug/2022:14:10:20 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 76 "-" "Wget" "AYJe40vLcPXxgssFAAAH"
10.244.3.1 - - [02/Aug/2022:14:10:50 +0000] "GET /devsonarqube/api/system/liveness HTTP/1.1" 204 - "-" "kube-probe/1.23" "AYJe40vLcPXxgssFAAAI"
10.244.3.35 - - [02/Aug/2022:14:10:50 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 76 "-" "Wget" "AYJe40vLcPXxgssFAAAJ"
10.244.3.1 - - [02/Aug/2022:14:11:20 +0000] "GET /devsonarqube/api/system/liveness HTTP/1.1" 204 - "-" "kube-probe/1.23" "AYJe40vLcPXxgssFAAAK"
10.244.3.35 - - [02/Aug/2022:14:11:20 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 76 "-" "Wget" "AYJe40vLcPXxgssFAAAL"
10.244.3.1 - - [02/Aug/2022:14:11:50 +0000] "GET /devsonarqube/api/system/liveness HTTP/1.1" 204 - "-" "kube-probe/1.23" "AYJe40vLcPXxgssFAAAM"
10.244.3.35 - - [02/Aug/2022:14:11:50 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 76 "-" "Wget" "AYJe40vLcPXxgssFAAAN"
10.244.3.1 - - [02/Aug/2022:14:12:20 +0000] "GET /devsonarqube/api/system/liveness HTTP/1.1" 204 - "-" "kube-probe/1.23" "AYJe40vLcPXxgssFAAAO"
10.244.3.35 - - [02/Aug/2022:14:12:20 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 76 "-" "Wget" "AYJe40vLcPXxgssFAAAP"
10.244.3.1 - - [02/Aug/2022:14:12:50 +0000] "GET /devsonarqube/api/system/liveness HTTP/1.1" 204 - "-" "kube-probe/1.23" "AYJe40vLcPXxgssFAAAQ"
10.244.3.35 - - [02/Aug/2022:14:12:50 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 76 "-" "Wget" "AYJe40vLcPXxgssFAAAR"
10.244.3.1 - - [02/Aug/2022:14:13:20 +0000] "GET /devsonarqube/api/system/liveness HTTP/1.1" 204 - "-" "kube-probe/1.23" "AYJe40vLcPXxgssFAAAS"
10.244.3.35 - - [02/Aug/2022:14:13:20 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 76 "-" "Wget" "AYJe40vLcPXxgssFAAAT"
10.244.3.1 - - [02/Aug/2022:14:13:50 +0000] "GET /devsonarqube/api/system/liveness HTTP/1.1" 204 - "-" "kube-probe/1.23" "AYJe40vLcPXxgssFAAAU"
10.244.3.35 - - [02/Aug/2022:14:13:50 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 76 "-" "Wget" "AYJe40vLcPXxgssFAAAV"
10.244.3.1 - - [02/Aug/2022:14:14:20 +0000] "GET /devsonarqube/api/system/liveness HTTP/1.1" 204 - "-" "kube-probe/1.23" "AYJe40vLcPXxgssFAAAW"
10.244.3.35 - - [02/Aug/2022:14:14:20 +0000] "GET /devsonarqube/api/system/status HTTP/1.1" 200 76 "-" "Wget" "AYJe40vLcPXxgssFAAAX"

Hello @anil_vijay ,

Welcome to Sonar Community :sonar:

This error is typical of corporate or proxy configuration issues. Please check with your network/infratructure team and check that you can communicate (i.e. curl) from your machine where analysis is located to the SonarQube server.

Hi Joe,

According to the logs I guess sonar analysis completed and uploaded, in fact prior to failing with 503 error the same api call returned 200 OK 5 times (eg: GET 200 http://xxx.ibm.com/devsonarqube/api/ce/task?id=AYJe4Z-W5yr_OQLZjvgO ). Do you think still we need to look into the network configuration?

Yes, there is some issue with networking still. Every 5 minutes is a check on that task and something just stopped it. Does this failure occur after 30 minutes on each quality gate status check? Is there a pattern to this failure in your analyses?

I recommend checking your CE logs at DEBUG level on SonarQube to see what issue could be occurring:

  • Change your Log Level to DEBUG (Administration > System > Log Level) - no need to restart SonarQube
  • Reproduce your issue
  • Change your Log Level back to INFO
  • Zip and attach your $SQ_HOME/logs folder here

logs.zip (400.3 KB)
I have uploaded the logs as you suggested.
Few more observation are,

  • If the project is very small the analysis is successful and quality gate status as well updated properly
  • But if the project is fairly large it is getting errored out and I suspect it is leading to the restart of the sonar server pod instance.

@Joe
Any update on this? Did you get a chance look at the logs?

Hi @Joe
I have got the issue resolved by increasing the resource limit of the pod container.
Thanks for all the support.

1 Like

Thanks for the update and notifying me of the resolution! Glad you resolved it.


Sidenote: You can disable this warning:

2022.08.04 12:59:17 ERROR web[AYJp/F2iW/paWsxIAAAl][o.s.s.p.UpdateCenterClient] Fail to connect to update center
org.sonar.api.utils.SonarException: Fail to download: https://update.sonarsource.org/update-center.properties (no proxy)
	at org.sonar.core.util.DefaultHttpDownloader.failToDownload(DefaultHttpDownloader.java:157)
	at org.sonar.core.util.DefaultHttpDownloader.readString(DefaultHttpDownloader.java:115)
	at org.sonar.api.utils.UriReader.readString(UriReader.java:69)

by setting sonar.updatecenter.activate to false if you don’t intend for SonarQube to reach out to the public internet.

Ok sure thanks for that input