Issue Summary
When deleting an ephemeral agent template, any dedications to plans/projects/jobs that the template had are not removed from the database, causing the plan/job/project to only build if dedicated to another available agent.
Steps to Reproduce
- Create an ephemeral agent template
- Dedicate it to a plan
- Delete the template (not the assignment)
Expected Results
The agent dedication relationship between the plan and the ephemeral template should be automatically removed and the plan should now be able to run on any available agents (or any other existing agents/templates it's dedicated to)
Actual Results
The dedication is not removed from the database upon ephemeral template deletion, leaving orphaned entries. This causes the plan to only be runnable if it is dedicated to another existing, active agent/template again.
Workaround
- Shutdown Bamboo.
- Connect to the Bamboo database and run the following query to identify the agent assignments/dedications that are linked to deleted ephemeral agent templates:
SELECT aa.ASSIGNMENT_ID FROM AGENT_ASSIGNMENT aa LEFT JOIN EPHEMERAL_AGENT_TEMPLATE eat ON aa.EXECUTOR_ID = eat.EPHEMERAL_AGENT_TEMPLATE_ID WHERE eat.EPHEMERAL_AGENT_TEMPLATE_ID IS NULL AND aa.EXECUTOR_TYPE = 'EPHEMERAL';
- As a result, you'll get a list of IDs. E.g.,
assignment_id 1343494 1409025 1509080 - Copy all those IDs and paste them into the following query within the parentheses. Please note that each ID must be wrapped in single quotation marks, and there must be a comma between each ID. For example: WHERE aa.ASSIGNMENT_ID IN ('1343494', '1409025', '1509080')
- Query to update and run:
DELETE FROM AGENT_ASSIGNMENT WHERE ASSIGNMENT_ID IN (<IDs HERE>)
- Query to update and run:
- Once the query has completed, you can run the first query again (the SELECT one) to ensure there are no orphaned assignments anymore.
- Once everything is OK, you can start Bamboo up again and validate that the plan should now be able to run on the available agents.