Quick debugging tips for Xray DB connectivity

Quick debugging tips for Xray DB connectivity

AuthorFullName__c
Loren Yeung
articleNumber
000005088
ft:sourceType
Salesforce
FirstPublishedDate
2021-06-29T19:48:11Z
lastModifiedDate
2024-03-10T07:47:20Z
VersionNumber
4

Relevant for system.yaml installations only. At the time of this article, this is Xray 3.x+.

Xray's system.yaml take slightly different entries for the database, versus java based system.yamls like Artifactory's, even though both are postgres backed. Lets take a look at an example database snippet from Artifactory:

shared:
    database:
        type: postgresql
        driver: org.postgresql.Driver
        url: jdbc:postgresql://10.138.0.1:5432/artifactory
        username: artifactory
        password: <redacted>

Compared to Xray:
shared:
    database:
        type: postgresql
        driver: org.postgresql.Driver
        url: postgres://10.138.0.1:5432/xray
        username: xray
        password: <redacted>


They look quite similar, right? One common mistake is that administrators will use the same format across JFrog products, but the URL formatting is overlooked. Notice that Artifactory's is preceded by 'jdbc', whereas Xray has no such prefix. Artifactory is a java based product, and thus uses 'Java Database Connectivity'. Xray is written in Golang, thus has no need for one. Another common one is that Artifactory's url is 'postgresql://' but in Xray, it should be 'postgres://'

If these points are not addressed, Xray will assume that the url is incorrect, ignore the provided one, and will attempt to use a default url (localhost). This can result in odd errors such as the DB being "unreachable" or the user/password combination is wrong, depending on how your set up is, e.g.:

Critical error: exiting from Xray Program, reason: dial tcp 127.0.0.1:5432: connect: connection refused

so all together, it goes from:

url: jdbc:postgresql://10.138.0.1:5432/artifactory
to
url: postgres://10.138.0.1:5432/xray


Another point of contention is RabbitMQ. By default, the rabbitMQ password will be injected during installation, but sometimes a system.yaml is provided by other means, such as automation. 

If you see some errors like 403 for rabbitMQ, you may be missing the following section:
shared:
    rabbitMq:
        username: guest
        password: JFXR_RABBITMQ_COOKIE

The default password is 'JFXR_RABBITMQ_COOKIE'*. You can change the password by following the steps listed here:
https://www.jfrog.com/confluence/display/JFROG/Installing+Xray#InstallingXray-ChangingRabbitMQDatabaseCredentials

* if you upgraded from a 2.x instance, the default password is 'guest'

Remember to update the system.yaml if you do.