Sonarqube external postgres connectivity

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
  • how is SonarQube deployed: zip, Docker, Helm
    helm
  • what are you trying to achieve
    to integrate sonarqube with azure devops
  • what have you tried so far to achieve this
    implemented a sonarqube in a kubernetes setup but unable to create the sonarqube service in the kubernetes

SONARQUBE VERSION sonar-application-10.0.0.68432
POSTGRESQL VERSION 15.2
HELM VERSION v3.11.2
KUBERNETES VERSION 1.24

Please find the below mentioned error message from the logs

STEPS FOLLOWED

|STEP 1||helm repo add sonarqube https://SonarSource.github.io/helm-chart-sonarqube|
|STEP 2||helm repo update|
|STEP 3||kubectl create namespace sonarqube-lts|
STEP 4 : helm install -n sonarqube-lts sonarqube sonarqube/sonarqube-lts --values values.yaml

Attaching the values.yaml file for refernece.

2023.06.16 11:32:19 INFO web[o.s.p.ProcessEntryPoint] Starting Web Server
2023.06.16 11:32:23 INFO web[o.s.s.p.LogServerVersion] SonarQube Server / 10.0.0.68432 / 75dae6a655f49ac78b0a786f6c19b15085561af9
2023.06.16 11:32:23 INFO web[o.sonar.db.Database] Create JDBC data source for jdbc:postgresql://...:5432/sonarqube
2023.06.16 11:32:23 INFO web[c.z.h.HikariDataSource] HikariPool-1 - Starting…
2023.06.16 11:32:24 INFO web[c.z.h.p.HikariPool] HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@78e89bfe
2023.06.16 11:32:24 INFO web[c.z.h.HikariDataSource] HikariPool-1 - Start completed.
2023.06.16 11:32:28 INFO web[o.s.s.p.ServerFileSystemImpl] SonarQube home: /opt/sonarqube
2023.06.16 11:32:28 INFO web[o.s.s.u.SystemPasscodeImpl] System authentication by passcode is enabled
2023.06.16 11:32:29 WARN web[o.s.c.a.AnnotationConfigApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘jdk.internal.loader.ClassLoaders$AppClassLoader@56113384-org.sonar.server.platform.db.migration.history.MigrationHistoryImpl’: Initialization of bean failed; nested exception is java.lang.IllegalStateException: Failed to read content of table schema_migrations
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘jdk.internal.loader.ClassLoaders$AppClassLoader@56113384-org.sonar.server.platform.db.migration.history.MigrationHistoryImpl’: Initialization of bean failed; nested exception is java.lang.IllegalStateException: Failed to read content of table schema_migrations
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:920)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:187)
at org.sonar.server.platform.platformlevel.PlatformLevel.start(PlatformLevel.java:80)
at org.sonar.server.platform.platformlevel.PlatformLevel2.start(PlatformLevel2.java:101)
at org.sonar.server.platform.PlatformImpl.start(PlatformImpl.java:214)
at org.sonar.server.platform.PlatformImpl.startLevel2Container(PlatformImpl.java:186)
at org.sonar.server.platform.PlatformImpl.init(PlatformImpl.java:80)
at org.sonar.server.platform.web.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:43)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4764)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5222)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1383)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1383)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.base/java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:916)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:265)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:430)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.sonar.server.app.EmbeddedTomcat.start(EmbeddedTomcat.java:72)
at org.sonar.server.app.WebServer.start(WebServer.java:55)
at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:97)
at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:81)
at org.sonar.server.app.WebServer.main(WebServer.java:104)
Caused by: java.lang.IllegalStateException: Failed to read content of table schema_migrations
at org.sonar.server.platform.db.migration.history.MigrationHistoryImpl.getLastMigrationNumber(MigrationHistoryImpl.java:75)
at org.sonar.server.platform.db.migration.history.MigrationHistoryMeddler.meddle(MigrationHistoryMeddler.java:45)
at org.sonar.server.platform.db.migration.history.MigrationHistoryImpl.start(MigrationHistoryImpl.java:54)
at org.sonar.core.platform.StartableBeanPostProcessor.postProcessBeforeInitialization(StartableBeanPostProcessor.java:33)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
… 44 common frames omitted
Caused by: org.postgresql.util.PSQLException: ERROR: permission denied for table schema_migrations
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2676)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2366)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:356)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:496)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:413)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:333)
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:319)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:295)
at org.postgresql.jdbc.PgStatement.executeQuery(PgStatement.java:244)
at com.zaxxer.hikari.pool.ProxyStatement.executeQuery(ProxyStatement.java:110)
at com.zaxxer.hikari.pool.HikariProxyStatement.executeQuery(HikariProxyStatement.java)
at org.sonar.server.platform.db.migration.history.MigrationHistoryImpl.selectVersions(MigrationHistoryImpl.java:97)
at org.sonar.server.platform.db.migration.history.MigrationHistoryImpl.getLastMigrationNumber(MigrationHistoryImpl.java:68)
… 50 common frames omitted

can some one assist me on this where the problematic is ?
I have given the Correct JDBC URL and it was connected

post showing some other error message

*) System authentication by passcode is enabled
*) Failed to read content of table schema_migrations
*) ERROR: permission denied for table schema_migrations

ALSO FOR A FRESH SONARQUBE IMPLEMENTATION IN A KUBERNETES ENVIRONMENT – DO WE NEED TO CREATE ANY TABLES IN THE POSTGRESQL DATBASE WHICH WE ARE POINTING [ EXTERNAL DATABASE ]

values_yaml.zip (6.5 KB)

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

When i tried to give full access to the external postgresdb for a user sonar abd tried

receiving the beloe error messages

Caused by: org.postgresql.util.PSQLException: ERROR: relation “schema_migrations” already exists │
│ at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2676) │
│ at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2366) │
│ at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:356) │
│ at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:496) │
│ at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:413) │
│ at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:333) │
│ at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:319) │
│ at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:295) │
│ at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:290) │
│ at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:94) │
│ at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java) │
│ at org.sonar.server.platform.db.migration.history.MigrationHistoryTableImpl.execute(MigrationHistoryTableImpl.java:71) │
│ at org.sonar.server.platform.db.migration.history.MigrationHistoryTableImpl.createTable(MigrationHistoryTableImpl.java:59) │
│ at org.sonar.server.platform.db.migration.history.MigrationHistoryTableImpl.start(MigrationHistoryTableImpl.java:45) │
│ … 48 common frames omitted │
│ 2023.06.16 13:43:12 INFO web[c.z.h.HikariDataSource] HikariPool-1 - Shutdown initiated… │
│ 2023.06.16 13:43:12 INFO web[c.z.h.HikariDataSource] HikariPool-1 - Shutdown completed. │
│ 2023.06.16 13:43:12 WARN web[o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [HikariPool-1 connection │
│ 2023.06.16 13:43:12 INFO web[o.s.s.a.EmbeddedTomcat] HTTP connector enabled on port 9000 │
│ 2023.06.16 13:43:12 INFO web[o.s.p.ProcessEntryPoint] Hard stopping process │
│ 2023.06.16 13:43:12 INFO app[o.s.a.SchedulerImpl] Process[Web Server] is stopped │
│ 2023.06.16 13:43:12 WARN app[o.s.a.p.AbstractManagedProcess] Process exited with exit value [ElasticSearch]: 143 │
│ 2023.06.16 13:43:12 INFO app[o.s.a.SchedulerImpl] Process[ElasticSearch] is stopped │
│ 2023.06.16 13:43:12 INFO app[o.s.a.SchedulerImpl] SonarQube is stopped