How to identify and remove Bamboo agent dedication from the database
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Fisheye および Crucible は除く
本記事で説明している手順は、現時点でのものとなります。そのため、一部のお客様で特定の状況下で動作したという報告がありますが、正式にサポートされているわけではなく、お客様の特定のシナリオで動作することを保証するものではありません。
本番環境での実施の前に一通り非本番環境で検証し、成功しなかった場合にはサポートされている代替案にフォール バックしてください。
要約
Agent dedication is usually done through the Bamboo UI ("Dedicating an agent"). Some use cases might require Bamboo admins to remove agent dedication in bulk, which is not possible from the UI. The purpose of this article is to help you identify and remove agent dedication from the database.
環境
- The queries have been tested on PostgreSQL and might need to be changed to work on other database types.
- The queries have been tested against Bamboo 8 but will likely work with other versions of Bamboo.
ソリューション
Listing agent dedication
Use the following query to get a list of agents that have been dedicated in your Bamboo instance:
SELECT DISTINCT AA.ASSIGNMENT_ID,
Q.TITLE AGENT_NAME,
Q.AGENT_TYPE,
AA.EXECUTABLE_TYPE OBJECT_TYPE,
AA.EXECUTABLE_ID OBJECT_ID
FROM AGENT_ASSIGNMENT AA,
QUEUE Q
WHERE AA.EXECUTOR_ID = Q.QUEUE_ID;
The output of the query should look like this:
ASSIGNMENT_ID | AGENT_NAME | AGENT_TYPE | OBJECT_TYPE | OBJECT_ID |
---|---|---|---|---|
950273 | Default Agent | LOCAL | PROJECT | 622593 |
950274 | Default Agent | LOCAL | PLAN | 720897 |
950275 | Default Agent | LOCAL | JOB | 720898 |
950276 | 192.168.10.116 | REMOTE | DEPLOYMENT_PROJECT | 983041 |
950277 | 192.168.10.116 | REMOTE | ENVIRONMENT | 1048577 |
In the example above you can see the following details:
- We have two agents that have been dedicated to different objects named Default Agent and 192.168.10.116.
- Each row represents an agent dedication to a certain object. There are only five types of objects: PROJECT, PLAN, JOB, DEPLOYMENT_PROJECT, and ENVIRONMENT.
- A local agent named Default Agent has been dedicated to a project, plan, and job.
- A remote agent named 192.168.10.116 has been dedicated to a deployment project and an environment.
The query will not give you the name of the objects but it will give you their IDs. The IDs can be used to identify the objects that the agents have been dedicated to using the following queries:
Finding PROJECT detailsSELECT PROJECT_ID, PROJECT_KEY, TITLE FROM PROJECT WHERE PROJECT_ID = <replaceWithObjectID>;
Finding PLAN & JOB detailsSELECT BUILD_ID, BUILD_TYPE, FULL_KEY, TITLE FROM BUILD WHERE BUILD_ID = <replaceWithObjectID>;
Finding DEPLOYMENT_PROJECT detailsSELECT DEPLOYMENT_PROJECT_ID, NAME DEPLOYMENT_PROJECT_NAME, PLAN_KEY SOURCE_BUILD_PLAN FROM DEPLOYMENT_PROJECT WHERE DEPLOYMENT_PROJECT_ID = <replaceWithObjectID>;
Finding ENVIRONMENT detailsSELECT DE.ENVIRONMENT_ID, DE.NAME ENVIRONMENT_NAME, DP.NAME DEPLOYMENT_PROJECT_NAME FROM DEPLOYMENT_ENVIRONMENT DE, DEPLOYMENT_PROJECT DP WHERE DE.PACKAGE_DEFINITION_ID = DP.DEPLOYMENT_PROJECT_ID AND ENVIRONMENT_ID = <replaceWithObjectID>;
Following the example above, if we want to know what are the names of the plan and job that the Default Agent has been dedicated to we can use the following select query:
SELECT BUILD_ID,
BUILD_TYPE,
FULL_KEY,
TITLE
FROM BUILD
WHERE BUILD_ID IN (720897,720898);
BUILD_ID | BUILD_TYPE | FULL_KEY | タイトル |
---|---|---|---|
720897 | CHAIN | PROJ-PLAN | My Plan |
720898 | JOB | PROJ-PLAN-JOB1 | Default Job |
Removing agent dedication
データベースの変更を行う場合は必ず事前にバックアップを取得してください。可能な場合は、まずステージング サーバーで SQL コマンドの変更、挿入、更新、または削除を行うようにします。
In order to remove the agent dedication you need to identify the row that holds the dedication you want to delete and take note of its ASSIGNMENT_ID. You'll find the ASSIGNMENT_ID of the row that needs to be removed in the result from the first select query mentioned under the "Listing agent dedication" section. Once you have the ID you can run the following delete query:
DELETE FROM AGENT_ASSIGNMENT
WHERE ASSIGNMENT_ID = <replaceWithAssignmentID>;
Taking the example we've been following, if we want to remove dedication from the Default Agent on the plan and job mentioned previously we have to run:
ASSIGNMENT_ID | AGENT_NAME | AGENT_TYPE | OBJECT_TYPE | OBJECT_ID |
---|---|---|---|---|
950274 | Default Agent | LOCAL | PLAN | 720897 |
950275 | Default Agent | LOCAL | JOB | 720898 |
DELETE FROM AGENT_ASSIGNMENT
WHERE ASSIGNMENT_ID in (950274,950275);