Unable to remove unused agents from Release Automation (RA), doing so result in below errors.
Unexpected error on server [Could not delete agent: ABC1DEFX. Reason: You cannot delete a server that is being used by one or more Releases. Please review [Release Detail .....]].
Release Automation 6.x
There are some unattended releases in system which are in state of validation pending, post deployment pending etc. which is blocking the removal of unused agents. These release may not be visible is list populated via JMX getAllActiveReleases as they are not yet in running state.
As a general administrative practice, RA administrator as part of maintenance activity should be cleaning the system of such unattended releases. The same can be done as mentioned below
1: Login to ROC as superuser
2: Navigate to ROC -> Releases -> Deployments
3: Filter releases by Application and status i.e. Pending, Approval
4: From the displayed list select the releases in Pending, Approval state and Remove Selected Deployments
5: After all unattended Deployments in state of Running, Pending, Approval from each Applications are removed, try to remove the unused agents.
To remove releases which are in status of running or hung, follow instruction as described in knowledge document below.