vanderby / SonarQube-AzureAppService

Instructions and files to host SonarQube on an Azure App Service without a container.
MIT License
90 stars 165 forks source link

Elastic Search permission denied #65

Open donald93 opened 2 years ago

donald93 commented 2 years ago

Hello, I'm seeing some issues trying set up a new App Service. There is an existing database I'm attempting to connect to. My SQL Server and App Service are set up on the same v-net and I've tested their connection through the App Service network troubleshooting. Here's the logs I'm seeing:

10:18:37 PM Starting HttpPlatformHandler Script
10:18:37 PM Searching for sonar.properties file
10:18:38 PM File found at: D:\home\site\wwwroot\sonarqube-9.5.0.56709\conf\sonar.properties
10:18:38 PM Resetting properties.
10:18:38 PM Updating sonar.properties based on environment/application settings.
10:18:38 PM Setting sonar.jdbc.password to XXXXXXXXXX
10:18:38 PM Setting sonar.jdbc.url to jdbc:sqlserver://XXXXXXXXXX:1433;database=sonarqube;encrypt=true;
10:18:38 PM Setting sonar.jdbc.username to sonar-admin
10:18:38 PM HTTP_PLATFORM_PORT is: 6226
10:18:38 PM Updating sonar.web.port to 6226
10:18:38 PM Saving updated sonar.properties contents
10:18:38 PM Searching for wrapper.conf file
10:18:39 PM File found at: D:\home\site\wwwroot\sonarqube-9.5.0.56709\conf\wrapper.conf
10:18:39 PM Writing to wrapper.conf file
10:18:39 PM Searching for duplicate plugins.
Compare-Object : Cannot bind argument to parameter 'ReferenceObject' because 
it is null.
At D:\home\site\wwwroot\HttpPlatformHandlerStartup.ps1:97 char:47
+ $duplicates = Compare-Object -ReferenceObject $uniquePlugins -Differe ...
+                                               ~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Compare-Object], ParameterBind 
   ingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M 
   icrosoft.PowerShell.Commands.CompareObjectCommand

10:18:39 PM Searching for StartSonar.bat
10:18:40 PM File found at: D:\home\site\wwwroot\sonarqube-9.5.0.56709\bin\windows-x86-64\StartSonar.bat
10:18:40 PM Executing StartSonar.bat
wrapper  | Attempt to set the console title failed: The handle is invalid. (0x6)
wrapper  | --> Wrapper Started as Console
wrapper  | Launching a JVM...
jvm 1    | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
jvm 1    |   Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.
jvm 1    | 
jvm 1    | 2022.07.11 22:18:45 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory D:\home\site\wwwroot\sonarqube-9.5.0.56709\temp
jvm 1    | 2022.07.11 22:18:45 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on [HTTP: 127.0.0.1:9001, TCP: 127.0.0.1:50606]
jvm 1    | 2022.07.11 22:18:46 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[ELASTICSEARCH] from [D:\home\site\wwwroot\sonarqube-9.5.0.56709\elasticsearch]: D:\Program Files\Java\microsoft-jdk-11.0.13.8\bin\java -XX:+UseG1GC -Djava.io.tmpdir=D:\home\site\wwwroot\sonarqube-9.5.0.56709\temp -XX:ErrorFile=../logs/es_hs_err_pid%p.log -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -Djna.tmpdir=D:\home\site\wwwroot\sonarqube-9.5.0.56709\temp -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dio.netty.allocator.numDirectArenas=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Dlog4j2.formatMsgNoLookups=true -Djava.locale.providers=COMPAT -Dcom.redhat.fips=false -Des.enforce.bootstrap.checks=true -Xmx512m -Xms512m -XX:MaxDirectMemorySize=256m -XX:+HeapDumpOnOutOfMemoryError -Delasticsearch -Des.path.home=D:\home\site\wwwroot\sonarqube-9.5.0.56709\elasticsearch -Des.path.conf=D:\home\site\wwwroot\sonarqube-9.5.0.56709\temp\conf\es -cp lib/* org.elasticsearch.bootstrap.Elasticsearch
jvm 1    | 2022.07.11 22:18:46 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
jvm 1    | 2022.07.11 22:18:51 ERROR app[][o.s.a.p.EsManagedProcess] Failed to check status
jvm 1    | org.elasticsearch.ElasticsearchException: java.util.concurrent.ExecutionException: java.net.SocketException: Permission denied: no further information
jvm 1    |  at org.elasticsearch.client.RestHighLevelClient.performClientRequest(RestHighLevelClient.java:2695)
jvm 1    |  at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:2171)
jvm 1    |  at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:2137)
jvm 1    |  at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:2105)
jvm 1    |  at org.elasticsearch.client.ClusterClient.health(ClusterClient.java:151)
jvm 1    |  at org.sonar.application.es.EsConnectorImpl.getClusterHealthStatus(EsConnectorImpl.java:64)
jvm 1    |  at org.sonar.application.process.EsManagedProcess.checkStatus(EsManagedProcess.java:92)
jvm 1    |  at org.sonar.application.process.EsManagedProcess.checkOperational(EsManagedProcess.java:77)
jvm 1    |  at org.sonar.application.process.EsManagedProcess.isOperational(EsManagedProcess.java:62)
jvm 1    |  at org.sonar.application.process.ManagedProcessHandler.refreshState(ManagedProcessHandler.java:223)
jvm 1    |  at org.sonar.application.process.ManagedProcessHandler$EventWatcher.run(ManagedProcessHandler.java:288)
jvm 1    | Caused by: java.util.concurrent.ExecutionException: java.net.SocketException: Permission denied: no further information
jvm 1    |  at org.elasticsearch.common.util.concurrent.BaseFuture$Sync.getValue(BaseFuture.java:257)
jvm 1    |  at org.elasticsearch.common.util.concurrent.BaseFuture$Sync.get(BaseFuture.java:244)
jvm 1    |  at org.elasticsearch.common.util.concurrent.BaseFuture.get(BaseFuture.java:75)
jvm 1    |  at org.elasticsearch.client.RestHighLevelClient.performClientRequest(RestHighLevelClient.java:2692)
jvm 1    |  ... 10 common frames omitted
jvm 1    | Caused by: java.net.SocketException: Permission denied: no further information
jvm 1    |  at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
jvm 1    |  at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:777)
jvm 1    |  at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:174)
jvm 1    |  at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:148)
jvm 1    |  at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:351)
jvm 1    |  at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:221)
jvm 1    |  at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64)
jvm 1    |  at java.base/java.lang.Thread.run(Thread.java:829)
jvm 1    | 2022.07.11 22:18:51 ERROR app[][o.s.a.p.EsManagedProcess] Failed to check status
jvm 1    | org.elasticsearch.ElasticsearchException: java.util.concurrent.ExecutionException: java.net.SocketException: Permission denied: no further information
jvm 1    |  at org.elasticsearch.client.RestHighLevelClient.performClientRequest(RestHighLevelClient.java:2695)
jvm 1    |  at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:2171)
jvm 1    |  at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:2137)
jvm 1    |  at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:2105)
jvm 1    |  at org.elasticsearch.client.ClusterClient.health(ClusterClient.java:151)
jvm 1    |  at org.sonar.application.es.EsConnectorImpl.getClusterHealthStatus(EsConnectorImpl.java:64)
jvm 1    |  at org.sonar.application.process.EsManagedProcess.checkStatus(EsManagedProcess.java:92)
jvm 1    |  at org.sonar.application.process.EsManagedProcess.checkOperational(EsManagedProcess.java:77)
jvm 1    |  at org.sonar.application.process.EsManagedProcess.isOperational(EsManagedProcess.java:62)
jvm 1    |  at org.sonar.application.process.ManagedProcessHandler.refreshState(ManagedProcessHandler.java:223)
jvm 1    |  at org.sonar.application.process.ManagedProcessHandler$EventWatcher.run(ManagedProcessHandler.java:288)
jvm 1    | Caused by: java.util.concurrent.ExecutionException: java.net.SocketException: Permission denied: no further information
jvm 1    |  at org.elasticsearch.common.util.concurrent.BaseFuture$Sync.getValue(BaseFuture.java:257)
jvm 1    |  at org.elasticsearch.common.util.concurrent.BaseFuture$Sync.get(BaseFuture.java:244)
jvm 1    |  at org.elasticsearch.common.util.concurrent.BaseFuture.get(BaseFuture.java:75)
jvm 1    |  at org.elasticsearch.client.RestHighLevelClient.performClientRequest(RestHighLevelClient.java:2692)
jvm 1    |  ... 10 common frames omitted
donald93 commented 2 years ago

Update: I tried setting things up with a completely fresh install so a new ASP, App Service, SQL Server, and database. I confirmed the App Service could connect to the SQL server through the vnet using the troubleshooter tool. Got the same errors.

JamieTemple commented 2 years ago

Just a quick note on my findings.

We were getting the same error, when provisioning a new version of SQ to a second deployment slot.

In short, we solved the problem by adding an extra (App Service) configuration parameter sonar.search.port with a value 0

My rough understanding of why this was happening is that the elastic search will run on port 9001, but (and here is the guess) if you already have a deployment slot running SQ with ES on this port, then a second slot cannot use the same port...

... hth ...