Skip to content

Commit a07297b

Browse files
committed
feat: add bypass-removal tag to prevent runner scale-down
Add support for ghr:bypass-removal EC2 tag that allows engineers to manually tag runners to prevent them from being scaled down during debugging or investigation. When this tag is set to 'true', the runner will be skipped during scale-down operations with appropriate logging.
1 parent 788570c commit a07297b

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

lambdas/functions/control-plane/src/aws/runners.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface RunnerList {
1111
org?: string;
1212
orphan?: boolean;
1313
runnerId?: string;
14+
bypassRemoval?: boolean;
1415
}
1516

1617
export interface RunnerInfo {

lambdas/functions/control-plane/src/aws/runners.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ function getRunnerInfo(runningInstances: DescribeInstancesResult) {
9393
org: i.Tags?.find((e) => e.Key === 'ghr:Org')?.Value as string,
9494
orphan: i.Tags?.find((e) => e.Key === 'ghr:orphan')?.Value === 'true',
9595
runnerId: i.Tags?.find((e) => e.Key === 'ghr:github_runner_id')?.Value as string,
96+
bypassRemoval: i.Tags?.find((e) => e.Key === 'ghr:bypass-removal')?.Value === 'true',
9697
});
9798
}
9899
}

lambdas/functions/control-plane/src/scale-runners/scale-down.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ function runnerMinimumTimeExceeded(runner: RunnerInfo): boolean {
130130
async function removeRunner(ec2runner: RunnerInfo, ghRunnerIds: number[]): Promise<void> {
131131
const githubAppClient = await getOrCreateOctokit(ec2runner);
132132
try {
133+
const runnerList = ec2runner as unknown as RunnerList;
134+
if (runnerList.bypassRemoval) {
135+
logger.info(
136+
`Runner '${ec2runner.instanceId}' has bypass-removal tag set, skipping removal. Remove the tag to allow scale-down.`,
137+
);
138+
return;
139+
}
140+
133141
const states = await Promise.all(
134142
ghRunnerIds.map(async (ghRunnerId) => {
135143
// Get busy state instead of using the output of listGitHubRunners(...) to minimize to race condition.

0 commit comments

Comments
 (0)