XRAY: How to reset Xray 3.x connection with the JFrog platform
This article will cover how to reset JFrog Xray when it is successfully set up with a new Artifactory instance but fails to establish a connection to Postgres database. This can be seen when a swap was made between two Artifactory instances and due to this we might not be able to do anything in ‘Indexed Resources’.
Error:Under Xray > Settings > Indexed Resources > Repositories, the ‘Add a repository’ button is greyed out and no Repositories are available to be added. Similar error is shown in Builds as well.
Steps to reset the Artifactory connection with Xray:
1. Take the backup of the Xray database from Postgres server.
2. Shut down the Xray service.
3. Login to PostgreSQL database server and enter the credentials:
psql -U xray xraydb
4. Look for binary_managers table and copy the id of the previous Artifactory instance:
SELECT * FROM binary_managers;
5. Delete that entry in binary_managers table using Artifactory instance id:
DELETE FROM binary_managers WHERE id='<previous_artifactory_id>';
6. Check binary_managers_indexed_resources table as well and perform the same delete procedure if any entries are found. Note we can not delete entries from the binary_managers table if we have data in binary_managers_indexed_resources table as it has a foreign key reference.
7. Start the Xray service and check Indexed Resources > Repositories.
Please note that we need to add the existing indexed resources again post the restart. Above steps should help to reset the Xray connection with Artifactory in the JFrog platform.