Skip to content

Commit bfba0f5

Browse files
committed
add test and documentation
1 parent f020057 commit bfba0f5

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

docs/additional_notes.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,31 @@ If default labels are removed:
3232
| 'custom5' | Linux | no match |
3333
| 'custom5' | [ self-hosted, Linux ] | no match |
3434
| 'custom5' | [ custom5, self-hosted, Linux ] | no match |
35+
36+
# Preventing Runner Scale-Down for Debugging
37+
38+
The module supports a bypass mechanism that allows you to prevent specific runners from being scaled down during debugging or investigation. This is useful when you need to access a runner instance directly to troubleshoot issues.
39+
40+
## Usage
41+
42+
To prevent a runner from being terminated during scale-down operations, add the `ghr:bypass-removal` tag to the EC2 instance with a value of `true`:
43+
44+
```bash
45+
aws ec2 create-tags --resources <instance-id> --tags Key=ghr:bypass-removal,Value=true
46+
```
47+
48+
When this tag is set, the scale-down process will skip the runner and log a message indicating that the runner is protected:
49+
50+
```
51+
Runner 'i-xxxxxxxxxxxx' has bypass-removal tag set, skipping removal. Remove the tag to allow scale-down.
52+
```
53+
54+
## Removing the Protection
55+
56+
Once you've finished debugging and want to allow the runner to be scaled down normally, remove the tag or set it to any other value:
57+
58+
```bash
59+
aws ec2 delete-tags --resources <instance-id> --tags Key=ghr:bypass-removal
60+
```
61+
62+
**Note:** The bypass-removal tag only prevents automatic scale-down. The runner will still continue to process job(s) as normal. Make sure to remove the tag after debugging to ensure proper resource management. It will also still terminate itself if the instance is empheral and the job is complete.

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,25 @@ describe('Scale down runners', () => {
286286
checkNonTerminated(runners);
287287
});
288288

289+
it(`Should not terminate runner with bypass-removal tag set.`, async () => {
290+
// setup
291+
const runners = [
292+
createRunnerTestData('idle-with-bypass', type, MINIMUM_TIME_RUNNING_IN_MINUTES + 10, true, false, false),
293+
];
294+
// Set bypass-removal tag
295+
runners[0].bypassRemoval = true;
296+
297+
mockGitHubRunners(runners);
298+
mockAwsRunners(runners);
299+
300+
// act
301+
await scaleDown();
302+
303+
// assert
304+
expect(terminateRunner).not.toHaveBeenCalled();
305+
checkNonTerminated(runners);
306+
});
307+
289308
it(`Should not terminate a runner that became busy just before deregister runner.`, async () => {
290309
// setup
291310
const runners = [

0 commit comments

Comments
 (0)