Search code examples
sonarqubeansibledatabase-migrationsonarqube5.6

SonarQube replying with NO_MIGRATION although db migration is required


We have automated the SonarQube server installation using Ansible. As part of this procedure, Ansible polls the URL sonar/api/server/index to check whether the server is up-and-running. As soon as an HTTP 200 is returned and the server status is equal to SETUP...

<server>
    <id>20170131094026</id>
    <version>5.6.2</version>
    <status>SETUP</status>
</server>

... the script triggers a database upgrade by sending a POST to sonar/api/server/setup and waiting for MIGRATION_SUCCEEDED to be returned.

This has worked well until now that I tried to upgrade SonarQube from version 5.6.2 to 5.6.5. For some reason sonar/api/server/index now always returns the status UP (even though the GUI clearly indicates that it's still under maintenance) and a POST to sonar/api/server/setup indicates that the database is up-to-date and no migration is needed (NO_MIGRATION).

However, the server is still in maintenance mode and the nexus.log keeps repeating the same line:

09:41:05 INFO  ce[o.s.c.a.WebServerWatcherImpl] Still waiting for WebServer...
09:41:39 INFO  ce[o.s.c.a.WebServerWatcherImpl] Still waiting for WebServer...
09:43:13 INFO  ce[o.s.c.a.WebServerWatcherImpl] Still waiting for WebServer...
09:47:28 INFO  ce[o.s.c.a.WebServerWatcherImpl] Still waiting for WebServer...

When I manually navigate to sonar/setup and click on the Update button, then a database migration starts... Has there been any changes in the API? Am I calling the wrong REST endpoints?


Solution

  • You're using internal web services (api/server/index and api/server/upgrade). Responses and behavior can change between versions without any notification.

    You should use instead :

    1. GET api/system/db_migration_status : to get the database migration status
    2. POST api/system/migrate_db : to execute the migration

    I encourage you to go to http:///web_api to see documentation of available web services for the version of SonarQube your using.