Must-share information (formatted with Markdown):
- which versions are you using (SonarQube Server / Community Build, Scanner, Plugin, and any relevant extension)
EKS version 1.30 and will soon move to 1.31
Helm version trying to install - Chart version - 8.0.8+3946 / SonarQube 9.9 LTA
Postgres DB - version 13
- how is SonarQube deployed: zip, Docker, Helm
Currently deployed - zip
Trying to migrate to - helm deployment - what are you trying to achieve
- Trying to migrate sonarqube from zip to helm deployment so basically trying to migrate the postgres DB after createing new postgres DB from snapshot of the older DB.
Postgres SQL version in both the cases - version 13
- what have you tried so far to achieve this
Few more details before I explain what I have tried
- Currently deployed zip sonarqube version - * Version 8.9.10 (build 61524)
- Currently deployed Postgres version - 13
- New Database postgres version - 13 stored with the snapshot of above older DB with the exact same username and password
- Trying to move to helm chart version 10.7.0+3598 here
But it throws an error that I should move to 9.9 LTA version first. - So trying to move to this helm chart version first
What I have tried so far -
- I have created blank postgres DB version 13 with the exact same config and secrets and username and password and with helm chart version 10.7.0+3598 and it works fine.
used below secret config for the same:
target:
name: sonarqube-jdbc
creationPolicy: Owner
data:
- secretKey: jdbc-password
remoteRef:
key: /shared/sonarqube-k8s/jdbcpassword
And
jdbcUsername: "sonar"
# Use this if you don't mind the DB password getting stored in plain text within the values file
jdbcSecretName: "sonarqube-jdbc"
jdbcSecretPasswordKey: "jdbc-password"
This works fine and sonarqube is up and running. So this step rules out any network related issues as the DB is being installed with the same network configs and helm chart is also installed on the same cluster.
- Then I created DB with the snapshot of older DB with same versions, configs, username and password and helm chart version 10.7.0+3598 but this step gives below error -
at org.sonar.server.app.WebServer.main(WebServer.java:104)
Caused by: org.sonar.api.utils.MessageException: The version of SonarQube you are trying to upgrade from is too old. Please upgrade to the 9.9 Long-Term Active version first.
2025.01.20 12:41:12 INFO web[][c.z.h.HikariDataSource] HikariPool-1 - Shutdown initiated...
2025.01.20 12:41:12 INFO web[][c.z.h.HikariDataSource] HikariPool-1 - Shutdown completed.
2025.01.20 12:41:12 INFO web[][o.s.p.ProcessEntryPoint] Hard stopping process
2025.01.20 12:41:12 INFO app[][o.s.a.SchedulerImpl] Process[Web Server] is stopped
2025.01.20 12:41:13 WARN app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [ElasticSearch]: 143
2025.01.20 12:41:13 INFO app[][o.s.a.SchedulerImpl] Process[ElasticSearch] is stopped
- Then I used the same DB used in step 2 but this time with helm Chart version - 8.0.8+3946 and SonarQube 9.9 LTA and then when I am getting the actual issue with below errors -
error
2025.01.23 12:06:49 INFO web[][o.s.p.ProcessEntryPoint] Starting Web Server
2025.01.23 12:06:52 INFO web[][o.s.s.p.LogServerVersion] SonarQube Server / 9.9.8.100196 / a6b73d92af974da59414bc4a00dde2882016ea70
2025.01.23 12:06:52 INFO web[][o.sonar.db.Database] Create JDBC data source for jdbc:postgresql://%!s(<nil>):5432/sonarDB
2025.01.23 12:06:52 INFO web[][c.z.h.HikariDataSource] HikariPool-1 - Starting...
2025.01.23 12:06:53 ERROR web[][c.z.h.p.HikariPool] HikariPool-1 - Exception during pool initialization.
org.postgresql.util.PSQLException: The connection attempt failed.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:331)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:247)
at org.postgresql.Driver.makeConnection(Driver.java:434)
at org.postgresql.Driver.connect(Driver.java:291)
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:121)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:100)
at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81)
at org.sonar.db.DefaultDatabase.createHikariDataSource(DefaultDatabase.java:159)
at org.sonar.db.DefaultDatabase.initDataSource(DefaultDatabase.java:148)
at org.sonar.db.DefaultDatabase.start(DefaultDatabase.java:126)
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)
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.PlatformLevel1.start(PlatformLevel1.java:164)
at org.sonar.server.platform.PlatformImpl.start(PlatformImpl.java:196)
at org.sonar.server.platform.PlatformImpl.startLevel1Container(PlatformImpl.java:162)
at org.sonar.server.platform.PlatformImpl.init(PlatformImpl.java:76)
at org.sonar.server.platform.web.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:43)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4005)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4446)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1203)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1193)
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:749)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:721)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1203)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1193)
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:749)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:211)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:415)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:874)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
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.net.UnknownHostException: %!s(<nil>)
at java.base/sun.nio.ch.NioSocketImpl.connect(Unknown Source)
at java.base/java.net.SocksSocketImpl.connect(Unknown Source)
at java.base/java.net.Socket.connect(Unknown Source)
at org.postgresql.core.PGStream.createSocket(PGStream.java:241)
at org.postgresql.core.PGStream.<init>(PGStream.java:98)
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:109)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:235)
... 62 common frames omitted
2025.01.23 12:06:53 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@163d04ff-org.sonar.db.DefaultDatabase': Initialization of bean failed; nested exception is java.lang.IllegalStateException: Fail to connect to database
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader@163d04ff-org.sonar.db.DefaultDatabase': Initialization of bean failed; nested exception is java.lang.IllegalStateException: Fail to connect to database
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.PlatformLevel1.start(PlatformLevel1.java:164)
at org.sonar.server.platform.PlatformImpl.start(PlatformImpl.java:196)
at org.sonar.server.platform.PlatformImpl.startLevel1Container(PlatformImpl.java:162)
at org.sonar.server.platform.PlatformImpl.init(PlatformImpl.java:76)
at org.sonar.server.platform.web.PlatformServletContextListener.contextInitialized(PlatformServletContextListener.java:43)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4005)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4446)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1203)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1193)
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:749)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:721)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1203)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1193)
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:749)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:211)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:415)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:874)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164)
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: Fail to connect to database
at org.sonar.db.DefaultDatabase.start(DefaultDatabase.java:130)
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: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: The connection attempt failed.
at com.zaxxer.hikari.pool.HikariPool.throwPoolInitializationException(HikariPool.java:596)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:582)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:100)
at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81)
at org.sonar.db.DefaultDatabase.createHikariDataSource(DefaultDatabase.java:159)
at org.sonar.db.DefaultDatabase.initDataSource(DefaultDatabase.java:148)
at org.sonar.db.DefaultDatabase.start(DefaultDatabase.java:126)
... 48 common frames omitted
Caused by: org.postgresql.util.PSQLException: The connection attempt failed.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:331)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:247)
at org.postgresql.Driver.makeConnection(Driver.java:434)
at org.postgresql.Driver.connect(Driver.java:291)
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:121)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561)
... 53 common frames omitted
Caused by: java.net.UnknownHostException: %!s(<nil>)
at java.base/sun.nio.ch.NioSocketImpl.connect(Unknown Source)
at java.base/java.net.SocksSocketImpl.connect(Unknown Source)
at java.base/java.net.Socket.connect(Unknown Source)
at org.postgresql.core.PGStream.createSocket(PGStream.java:241)
at org.postgresql.core.PGStream.<init>(PGStream.java:98)
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:109)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:235)
... 62 common frames omitted
2025.01.23 12:06:54 INFO web[][o.s.s.a.EmbeddedTomcat] HTTP connector enabled on port 9000
2025.01.23 12:06:54 INFO web[][o.s.p.ProcessEntryPoint] Hard stopping process
2025.01.23 12:06:54 INFO app[][o.s.a.SchedulerImpl] Process[Web Server] is stopped
2025.01.23 12:06:54 WARN app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [ElasticSearch]: 143
2025.01.23 12:06:54 INFO app[][o.s.a.SchedulerImpl] Process[ElasticSearch] is stopped
2025.01.23 12:06:54 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped
The helm chart page shows that this is compatible with k8s version 1.23 to 1.26, So not sure if the above issue is because of that though the error seems to be DB connection issues.
Also while installing this helm chart version it was looking for specifically for this secret sonarqube-sonarqube
so had to change the secret as below
target:
name: sonarqube-sonarqube
#name: sonarqube-sonarqube
creationPolicy: Owner
data:
- secretKey: jdbc-password
remoteRef:
key: /shared/sonarqube-k8s/jdbcpassword
and
jdbcUsername: "sonar"
# Use this if you don't mind the DB password getting stored in plain text within the values file
jdbcSecretName: "sonarqube-sonarqube"
jdbcSecretPasswordKey: "jdbc-password"
- So to rule out if the above issue could be because of the snapshot stored DB I used the DB created in step 1 , blank DB but just with the same version, config, username and password I created and helm Chart version - 8.0.8+3946 and SonarQube 9.9 LTA but still getting the same issue as above.
Config looks as below:
1.
secret,yaml
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: sonarqube-sonarqube
#name: sonarqube-sonarqube
namespace: sonarqube
spec:
refreshInterval: 1m
secretStoreRef:
kind: ClusterSecretStore
name: parameter-store
target:
name: sonarqube-sonarqube
#name: sonarqube-sonarqube
creationPolicy: Owner
data:
- secretKey: jdbc-password
remoteRef:
key: /aaa/sonarqube-k8s/jdbcpassword
values.yaml
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
name: sonarqube
namespace: sonarqube
spec:
releaseName: sonarqube
chart:
spec:
chart: sonarqube
version: 8.0.8+3946
sourceRef:
kind: HelmRepository
name: sonarqube
namespace: flux-system
interval: 5m
install:
remediation:
retries: 3
crds: CreateReplace
upgrade:
crds: CreateReplace
values:
replicaCount: 1
elasticsearch:
# DEPRECATED: Use initSysctl.enabled instead
configureNode: false
bootstrapChecks: false
ingress:
enabled: true
#className: alb
ingressClassName: alb
annotations:
#kubernetes.io/ingress.class: alb
#ingressClassName: alb
alb.ingress.kubernetes.io/ssl-redirect: "443"
#alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:us-east-1:aaa:certificate/aaa-vvv-cc-bbb-aaa
alb.ingress.kubernetes.io/healthcheck-path: /
alb.ingress.kubernetes.io/listen-ports: '[{"HTTPS": 443}]'
alb.ingress.kubernetes.io/load-balancer-attributes: access_logs.s3.enabled=true,access_logs.s3.bucket=aa-bb-prd-alb-logs
alb.ingress.kubernetes.io/scheme: internal
alb.ingress.kubernetes.io/security-groups: sg-aaa,sg-bb,sg-cc
#alb.ingress.kubernetes.io/subnets: subnet-aaa,subnet-bbb
alb.ingress.kubernetes.io/ssl-policy: ELBSecurityPolicy-TLS-1-2-2017-01
alb.ingress.kubernetes.io/success-codes: "200,303,301"
alb.ingress.kubernetes.io/target-type: ip
hosts:
- name: sonarqube.aaa.vv.bb.io
path: /*
pathType: ImplementationSpecific
## Override JDBC values
## for external Databases
jdbcOverwrite:
# (DEPRECATED) Please use jdbcOverwrite.enabled instead
# enable: false
# If enable the JDBC Overwrite, make sure to set `postgresql.enabled=false`
enabled: true
# The JDBC url of the external DB
jdbcUrl: "jdbc:postgresql://sonar-aaa-k8s-database.aaa.us-east-1.rds.amazonaws.com/sonar?currentSchema=public"
# The DB user that should be used for the JDBC connection
jdbcUsername: "sonar"
# Use this if you don't mind the DB password getting stored in plain text within the values file
jdbcSecretName: "sonarqube-sonarqube"
jdbcSecretPasswordKey: "jdbc-password"
postgresql:
# Enable to deploy the bitnami PostgreSQL chart
enabled: false
Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!
logs already shared above.