SonarQube: Change the elastic search client host

2019-01-29 03:29发布

问题:

In brief: Is there a way of changing the target address within the elastic search client used by SonarQube?

More Info: I'd love to use SonarQube > 4.1 on OpenShift. Unfortunately, you can't bind to localhost in that environment. So these guys changed the service wrapper to piped mode and used the sonar.web.host property to set up SonarQube 4.0. Starting with SonarQube 4.1 we'll also have the elastic search server that tries to bind to localhost, which leads to a crash at startup. But there's no such thing as a sonar.search.host property (similar to sonar.search.port), is there?

As a workaround, changing the binding of the server can be changed using the sonar.search.javaAdditionalOpts and es.network.host parameters. Yeah I know, I shouldn't be doing this. Because now the app crashes with a NoNodeAvailableException: No node available. That's why I'm looking for a way to change this.
Looking at SonarQubes source code, I presume that the client's target address is hard-coded. (I might have gotten that wrong, though)

I presume without a solution for this, we'll never SonarQube 5.0 running on OpenShift or any other environment with strict security policy.

Can anyone think of another workaround?
Maybe changing Java's definition for "localhost"/loopback interface? However, changing /etc/hosts doesn't work without root access. Any other ideas?

Edit: If you want to have a look yourself here's how far I got so far. The build file is the essential part.

回答1:

This is possible since SonarQube 5.2, using the sonar.search.host property.
For an example on how to deploy this on OpenShift, see here.



回答2:

In Sonar 5.2 will be possible to set these properties, see here . I have tried and it works (I changed this class in Sonar 5.1 source to allow configure these ES properties, see here).