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

[bitnami/sonarqube] Extensions doesn't get copied to application extension folder when the jvmOpts include a javaagent setting #55271

Open
codedreality opened this issue Jan 22, 2024 · 10 comments
Labels
on-hold Issues or Pull Requests with this label will never be considered stale sonarqube tech-issues The user has a technical issue about an application

Comments

@codedreality
Copy link

codedreality commented Jan 22, 2024

Name and Version

bitnami/sonarqube:10.3.0

What architecture are you using?

amd64

What steps will reproduce the bug?

Using bitnami/sonarqube chart version: 4.3.0 and configure it to install additional extensions, ex. the community branch plugin with the provisioning folder

  1. Setting SONAR_CE_JAVAADDITIONALOPTS to "-javaagent:/opt/bitnami/sonarqube/extensions/plugins/sonarqube-community-branch-plugin-1.18.0.jar=ce" and SONARQUBE_WEB_JAVA_ADD_OPTS to "-javaagent:/opt/bitnami/sonarqube/extensions/plugins/sonarqube-community-branch-plugin-1.18.0.jar=web".
  2. Setting
    plugins:
       install:
          - https://github.com/mc1arke/sonarqube-community-branch-plugin/releases/download/1.18.0/sonarqube-community-branch-plugin-1.18.0.jar
       containerSecurityContext: null
  3. Running the chart to deploy sonarqube

What is the expected behavior?

The container should start without an error.

What do you see instead?

Sonarqube exits with error 1 in the app initializing phase:

$ cat /opt/bitnami/sonarqube/logs/sonar.log:
2024.01.22 13:01:35 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/bitnami/sonarqube/temp
2024.01.22 13:01:35 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on [HTTP: 127.0.0.1:9001, TCP: 127.0.0.1:44067]
2024.01.22 13:01:35 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[ELASTICSEARCH] from [/opt/bitnami/sonarqube/elasticsearch]: /opt/bitnami/java/bin/java -Xms4m -Xmx64m -XX:+UseSerialGC -Dcli.name=server -Dcli.script=./bin/elasticsearch -Dcli.libs=lib/tools/server-cli -Des.path.home=/opt/bitnami/sonarqube/elasticsearch -Des.path.conf=/opt/bitnami/sonarqube/temp/conf/es -Des.distribution.type=tar -cp /opt/bitnami/sonarqube/elasticsearch/lib/*:/opt/bitnami/sonarqube/elasticsearch/lib/cli-launcher/* org.elasticsearch.launcher.CliToolLauncher
2024.01.22 13:01:35 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2024.01.22 13:01:41 INFO  app[][o.s.a.SchedulerImpl] Process[es] is up
2024.01.22 13:01:41 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[WEB_SERVER] from [/opt/bitnami/sonarqube]: /opt/bitnami/java/bin/java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=/opt/bitnami/sonarqube/temp -XX:-OmitStackTraceInFastThrow --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.management/sun.management=ALL-UNNAMED --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED -Dcom.redhat.fips=false -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -javaagent:/opt/bitnami/sonarqube/extensions/plugins/sonarqube-community-branch-plugin-1.18.0.jar=web -Dhttp.nonProxyHosts=localhost|127.*|[::1] -cp ./lib/sonar-application-10.3.0.82913.jar:/opt/bitnami/sonarqube/lib/jdbc/postgresql/postgresql-42.6.0.jar org.sonar.server.app.WebServer /opt/bitnami/sonarqube/temp/sq-process10894791941738552216properties
2024.01.22 13:01:41 WARN  app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [Web Server]: 1
2024.01.22 13:01:41 INFO  app[][o.s.a.SchedulerImpl] Process[Web Server] is stopped
2024.01.22 13:01:41 WARN  app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [ElasticSearch]: 143
2024.01.22 13:01:41 INFO  app[][o.s.a.SchedulerImpl] Process[ElasticSearch] is stopped
2024.01.22 13:01:41 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped
$ Pod Error - Log:
sonarqube 13:32:24.89 INFO ==>
sonarqube 13:32:24.89 INFO ==> Welcome to the Bitnami sonarqube container
sonarqube 13:32:24.89 INFO ==> Subscribe to project updates by watching https://github.com/bitnami/containers
sonarqube 13:32:24.89 INFO ==> Submit issues and feature requests at https://github.com/bitnami/containers/issues
sonarqube 13:32:24.89 INFO ==>
sonarqube 13:32:24.90 INFO ==> Validating settings in POSTGRESQL_CLIENT_* env vars
sonarqube 13:32:24.91 DEBUG ==> Validating settings in SONARQUBE_* environment variables...
sonarqube 13:32:24.92 INFO ==> Creating SonarQube configuration
sonarqube 13:32:24.92 DEBUG ==> Setting sonar.jdbc.username to 'xxxx' in SonarQube configuration
sonarqube 13:32:24.92 DEBUG ==> Setting sonar.jdbc.password to 'xxxx' in SonarQube configuration
sonarqube 13:32:24.93 DEBUG ==> Setting sonar.web.port to '9000' in SonarQube configuration
sonarqube 13:32:24.93 DEBUG ==> Setting sonar.web.host to '127.0.0.1' in SonarQube configuration
sonarqube 13:32:24.94 DEBUG ==> Setting sonar.search.port to '9001' in SonarQube configuration
sonarqube 13:32:24.94 DEBUG ==> Setting sonar.search.host to '127.0.0.1' in SonarQube configuration
sonarqube 13:32:24.95 DEBUG ==> Setting sonar.web.javaAdditionalOpts to '-javaagent:/opt/bitnami/sonarqube/extensions/plugins/sonarqube-community-branch-plugin-1.18.0.jar=web' in SonarQube configuration
sonarqube 13:32:24.95 DEBUG ==> Setting sonar.log.rollingPolicy to 'none' in SonarQube configuration
sonarqube 13:32:24.96 INFO ==> Trying to connect to the database server
sonarqube 13:32:45.01 INFO ==> Ensuring SonarQube directories exist
/opt/bitnami/java/bin/java
SonarQube is not running.
sonarqube 13:32:45.02 INFO ==> Starting SonarQube in background
/opt/bitnami/java/bin/java
Starting SonarQube...
Started SonarQube.
sonarqube 13:32:45.04 INFO ==> Waiting for SonarQube to start...
sonarqube 13:32:45.04 DEBUG ==> Checking that /opt/bitnami/sonarqube/logs/sonar.log log file contains entry "SonarQube is (up|operational)"
grep: /opt/bitnami/sonarqube/logs/sonar.log: No such file or directory
sonarqube 13:32:45.04 DEBUG ==> Entry "SonarQube is (up|operational)" still not present in /opt/bitnami/sonarqube/logs/sonar.log (attempt 1/150)
sonarqube 13:32:46.05 DEBUG ==> Entry "SonarQube is (up|operational)" still not present in /opt/bitnami/sonarqube/logs/sonar.log (attempt 2/150)
...

The InitContainer already downloaded the plugin and stored it in the provisioning-folder

$ ls /bitnami/sonarqube-provisioning/extensions/plugins/
sonarqube-community-branch-plugin-1.18.0.jar

Additional information

The file rootfs/opt/bitnamo/scripts/libsonarqube.sh defines function sonarqube_initialize which starts sonarqube to initialize the database if not already done.

The call to sonarqube_start_bg fails with the exit code 1 due to the fact that the jvmOpts are already set with the javaagent which is still not copied to the extension folder.

Afterwards persisting of the sonarqube installation and the copy from the $SONARQUBE_MOUNTED_PROVISIONING_DIR should run to copy the extension to the right folder, but this point is not reached due to the error above.

@codedreality codedreality added the tech-issues The user has a technical issue about an application label Jan 22, 2024
@github-actions github-actions bot added the triage Triage is needed label Jan 22, 2024
@carrodher
Copy link
Member

Thank you for bringing this issue to our attention. We appreciate your involvement! If you're interested in contributing a solution, we welcome you to create a pull request. The Bitnami team is excited to review your submission and offer feedback. You can find the contributing guidelines here.

Your contribution will greatly benefit the community. Feel free to reach out if you have any questions or need assistance.

Copy link

github-actions bot commented Feb 7, 2024

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

@github-actions github-actions bot added the stale 15 days without activity label Feb 7, 2024
@codedreality
Copy link
Author

What would be the best way to handle the chicken and egg problem of the timing and the way the volumes and paths are handled from the install and the sonarqube container . A possible solution would be to run the mount and copy (persist) two times, not ideal.

The original sonarqube chart copys the plugin directly to the application/extension folder, so i think the real solution would need some deeper changes in the way how the container handle the volumes and mounts.

Any thoughts what would be the best way to solve the issue with javaagents not available on starting th eapp first time?

@github-actions github-actions bot removed the stale 15 days without activity label Feb 9, 2024
@github-actions github-actions bot removed the triage Triage is needed label Feb 9, 2024
@github-actions github-actions bot assigned aoterolorenzo and unassigned carrodher Feb 9, 2024
Copy link

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

@github-actions github-actions bot added the stale 15 days without activity label Feb 25, 2024
@aoterolorenzo aoterolorenzo removed the stale 15 days without activity label Feb 26, 2024
@aoterolorenzo
Copy link
Contributor

hi @codedreality,

Could you try using $SONARQUBE_CE_JAVA_ADD_OPTS instead of $SONAR_CE_JAVAADDITIONALOPTS? I suspect that the first one if the one who passes through the bitnami scripts logic.

    # Java additional opts
    ! is_empty_value "$SONARQUBE_CE_JAVA_ADD_OPTS" && sonarqube_conf_set "sonar.ce.javaAdditionalOpts" "$SONARQUBE_CE_JAVA_ADD_OPTS"
    ! is_empty_value "$SONARQUBE_ELASTICSEARCH_JAVA_ADD_OPTS" && sonarqube_conf_set "sonar.search.javaAdditionalOpts" "$SONARQUBE_ELASTICSEARCH_JAVA_ADD_OPTS"
    ! is_empty_value "$SONARQUBE_WEB_JAVA_ADD_OPTS" && sonarqube_conf_set "sonar.web.javaAdditionalOpts" "$SONARQUBE_WEB_JAVA_ADD_OPTS"

@codedreality
Copy link
Author

codedreality commented Feb 26, 2024

No it exits with same error.

I although tried setting with extraProperties but since the string contains = in it, sonarqube_conf_set will concatenate the two strings and double them.

@aoterolorenzo
Copy link
Contributor

Let me create an internal task for the team to take a deeper look at the issue and create a fix. We will reach you back here as soon as our workload allow us.

@aoterolorenzo aoterolorenzo added the on-hold Issues or Pull Requests with this label will never be considered stale label Feb 28, 2024
@DanielFran
Copy link

@aoterolorenzo Found this project https://github.com/adrianmusante/docker-sonarqube that install the plugin on top of the bitnami sonarqube version.
Would be awesome that we could install the plugin without the need of using another image....

@carrodher
Copy link
Member

Thank you for bringing this issue to our attention. We appreciate your involvement! If you're interested in contributing a solution, we welcome you to create a pull request. The Bitnami team is excited to review your submission and offer feedback. You can find the contributing guidelines here.

Your contribution will greatly benefit the community. Feel free to reach out if you have any questions or need assistance.

@DanielFran
Copy link

Maybe @adrianmusante can contribute here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on-hold Issues or Pull Requests with this label will never be considered stale sonarqube tech-issues The user has a technical issue about an application
Projects
None yet
Development

No branches or pull requests

4 participants