Unable to do a sonarqube scan. Sonarqube is launched in a kubernetes cluster

Sonarqube docker image : 8.3.1
Please find the attached error messages

[DEBUG] 00:53:39.625 GET 404 http://<sonarqube_url>/api/settings/values.protobuf?component=project_name | time=21ms

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project <project_name>: Unable to load component class org.sonar.scanner.report.ActiveRulesPublisher: Unable to load component interface org.sonar.api.batch.rule.ActiveRules: Error 404 on http://<sonarqube_url>/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt&activation=true&qprofile=AXQLbywMmPpsUATThMYA&ps=500&p=1 : {"errors":[{"msg":"The specified qualityProfile 'AXQLbywMmPpsUATThMYA' does not exist"}]} -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project <project_name>: Unable to load component class org.sonar.scanner.report.ActiveRulesPublisher
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to load component class org.sonar.scanner.report.ActiveRulesPublisher
    at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute (ScannerBootstrapper.java:67)
    at org.sonarsource.scanner.maven.SonarQubeMojo.execute (SonarQubeMojo.java:104)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.report.ActiveRulesPublisher
    at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent (ComponentContainer.java:66)
    at org.picocontainer.DefaultPicoContainer.getComponent (DefaultPicoContainer.java:621)
    at org.picocontainer.parameters.CollectionComponentParameter.getArrayInstance (CollectionComponentParameter.java:334)
    at org.picocontainer.parameters.CollectionComponentParameter.access$100 (CollectionComponentParameter.java:49)
    at org.picocontainer.parameters.CollectionComponentParameter$1.resolveInstance (CollectionComponentParameter.java:139)
    at org.picocontainer.parameters.ComponentParameter$1.resolveInstance (ComponentParameter.java:141)
    at org.picocontainer.injectors.SingleMemberInjector.getParameter (SingleMemberInjector.java:78)
Caused by: java.lang.IllegalStateException: Unable to load component interface org.sonar.api.batch.rule.ActiveRules
    at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent (ComponentContainer.java:66)
    at org.picocontainer.DefaultPicoContainer.getComponent (DefaultPicoContainer.java:632)
    at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance (BasicComponentParameter.java:118)
    at org.picocontainer.parameters.ComponentParameter$1.resolveInstance (ComponentParameter.java:136)
    at org.picocontainer.injectors.SingleMemberInjector.getParameter (SingleMemberInjector.java:78)
    at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments (ConstructorInjector.java:309)
    at org.picocontainer.injectors.ConstructorInjector$1.run (ConstructorInjector.java:335)
    at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe (AbstractInjector.java:270)
    at org.picocontainer.injectors.ConstructorInjector.getComponentInstance (ConstructorInjector.java:364)
    at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance (AbstractInjectionFactory.java:56)
    at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance (AbstractBehavior.java:64)
    at org.picocontainer.behaviors.Stored.getComponentInstance (Stored.java:91)
    at org.picocontainer.DefaultPicoContainer.getInstance (DefaultPicoContainer.java:699)
    at org.picocontainer.DefaultPicoContainer.getComponent (DefaultPicoContainer.java:647)
    at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent (ComponentContainer.java:64)
Caused by: org.sonarqube.ws.client.HttpException: Error 404 on http://<sonarqube_url>/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives,createdAt,updatedAt&activation=true&qprofile=AXQLbywMmPpsUATThMYA&ps=500&p=1 : {"errors":[{"msg":"The specified qualityProfile 'AXQLbywMmPpsUATThMYA' does not exist"}]}
    at org.sonarqube.ws.client.BaseResponse.failIfNotSuccessful (BaseResponse.java:36)
    at org.sonar.scanner.bootstrap.DefaultScannerWsClient.failIfUnauthorized (DefaultScannerWsClient.java:112)
    at org.sonar.scanner.bootstrap.DefaultScannerWsClient.call (DefaultScannerWsClient.java:75)
    at org.sonar.scanner.rule.DefaultActiveRulesLoader.load (DefaultActiveRulesLoader.java:60)
    at org.sonar.scanner.rule.ActiveRulesProvider.load (ActiveRulesProvider.java:99)
    at org.sonar.scanner.rule.ActiveRulesProvider.load (ActiveRulesProvider.java:63)
    at org.sonar.scanner.rule.ActiveRulesProvider.provide (ActiveRulesProvider.java:50)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.picocontainer.injectors.MethodInjector.invokeMethod (MethodInjector.java:129)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[Pipeline] }
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeeded?

Hi @Poonam_Parihari ,

welcome to the community :wave:

Sonarqube on k8s is something that is currently not supported by sonarsource but we hope that this will change in the future.
Apart from that i think that your specific problem here has nothing to do with kubernetes

Please check the Project configuration and switch to a qualityprofile that is available within your instance

hope that helps

Hi Tobias,

We brought up 2 sonar pods in k8s using docker-image ‘sonarqube’-- community-edition (8.4.1). Its failing then with the above error.

But when we brought up a single pod using the same above image, a successful sonar scan was performed.

Could you please let us know, if multiple pods possible with community-edition image.
Moreover, could you please let us know if the community-edition supports cluster capabilities
Will having 2 pods connecting to single database, solve the issue?

Thanks,
Poonam

Hi @Poonam_Parihari ,

no the community edition is not meant to be clustered. we have the datacenter edition ($$) for this, but this one is currently not supported to be run on k8s (as in there is no docker image).
when there is more then one sq instance connected to the same database you will have a race condition on every scan if the data is consistent and in the worst case you will end up with a corrupted database, so please don’t do this :sweat_smile:
you can cluster the DB and the loadballancer in front of the community edition but not the application itself

Thank you so much for giving a clear picture :slight_smile: