Attempting to remove an agent (via Environments -> Agent Assignment) from an Environment is returning an error.
Failed to remove agents
Unexpected error on server [Failed to remove environment server, environment id [####], to be removed environment server ids [ #####]].
Please refer to server logs with timesgtamp [yyy-dd-mm hh:mm:ss].
or
Failed to remove agents
Unexpected error on server [Failed to clean up the environment server with id [####]]. Please refer to server logs with timesgtamp [yyy-dd-mm hh:mm:ss].
Release Automation - All Versions
This can happen if you're trying to remove the agent from an environment while that agent is currently in use by an active deployment.
The deployments that are currently using this agent need to be completed or cancelled before the agent can be removed from an environment via Agent Assignment.
The nolio_dm_all.log file may show a message similar to the following while trying to remove the agent that is used by an active deployment:
2021-12-01T12:07:41.784-05:00 [http-nio-18080-exec-2] ERROR (com.nolio.releasecenter.services.EnvironmentsRCServiceImpl:865) - Failed to clean up the environment server with id [181]
com.nolio.platform.server.dataservices.api.environments.AgentIsUsedException: Server is used in a step of one or more Releases: [TestRemoveAgent]