Repository navigation
feat(termination-watcher): support additional GitHub Apps - #5467
Merged
Merged
Conversation
guicaulada
force-pushed
the
gc/feat/janitor-multi-app
branch
from
September 23, 2026 14:36
89ee01e to
bfe90f4
Compare
guicaulada
changed the base branch from
gc/feat/registration-janitor
to
main
September 23, 2026 14:36
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
guicaulada
marked this pull request as ready for review
September 23, 2026 14:44
guicaulada
force-pushed
the
gc/feat/janitor-multi-app
branch
from
September 24, 2026 13:54
bfe90f4 to
1c503d3
Compare
guicaulada
force-pushed
the
gc/feat/janitor-multi-app
branch
from
October 5, 2026 14:04
1c503d3 to
f360cb5
Compare
guicaulada
force-pushed
the
gc/feat/janitor-multi-app
branch
from
October 14, 2026 12:35
f360cb5 to
859a69f
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Quota state mixes independent installations and retains stale budgets, which can select exhausted Apps or suppress recovered capacity.
3 open findings
What changed in this PR
Adds multi-App authentication to termination-watcher cleanup and SQS retries, using the existing credential store.
Changes:
- Adds quota-aware App selection, throttling cooldowns, and authentication fallback.
- Forwards manifest configuration and scoped SSM permissions through Terraform.
- Preserves the GHES endpoint on retries and adds tests and documentation.
| File | Description |
|---|---|
| modules/termination-watcher/variables.tf | Adds optional multi-App inputs. |
| modules/termination-watcher/tests/multi-app.tftest.hcl | Tests manifest wiring and configuration defaults. |
| modules/termination-watcher/termination/main.tf | Permits batched credential reads. |
| modules/termination-watcher/README.md | Documents multi-App support. |
| modules/termination-watcher/notification/main.tf | Permits batched credential reads. |
| modules/termination-watcher/main.tf | Wires manifest environment and parameter ARNs. |
| modules/termination-watcher/deregister-retry.tf | Extends retry credential permissions. |
| modules/multi-runner/termination-watcher.tf | Forwards additional-App configuration. |
| lambdas/functions/termination-watcher/src/github-app-client.ts | Implements App selection and paired authentication. |
| lambdas/functions/termination-watcher/src/github-app-client.test.ts | Tests selection, cooldowns, and fallback. |
| lambdas/functions/termination-watcher/src/deregister.ts | Uses shared authentication and retains retry endpoint. |
| lambdas/functions/termination-watcher/src/deregister.test.ts | Tests additional-App deregistration. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
guicaulada
force-pushed
the
gc/feat/janitor-multi-app
branch
3 times, most recently
from
October 19, 2026 14:27
02b0f49 to
a7bbecb
Compare
guicaulada
force-pushed
the
gc/feat/janitor-multi-app
branch
2 times, most recently
from
October 27, 2026 15:20
52155e5 to
ff1f47f
Compare
Brend-Smits
previously approved these changes
Oct 27, 2026
guicaulada
force-pushed
the
gc/feat/janitor-multi-app
branch
from
October 27, 2026 16:47
ff1f47f to
9694722
Compare
Brend-Smits
approved these changes
Oct 27, 2026
Brend-Smits
added a commit
to Brend-Smits/terraform-aws-github-runner
that referenced
this pull request
Oct 28, 2026
The termination notification, termination handler and deregister-retry Lambdas read the GitHub App credentials from SSM Parameter Store. When the parameters are SecureStrings encrypted with a customer-managed KMS key, the roles had no kms:Decrypt on it, so every read failed and runners were never deregistered. Add an optional github_app_kms_key_arn to the module config and build the credential-read policy once, so all three roles get the SSM actions and kms:Decrypt scoped to that key. The root module passes kms_key_arn and multi-runner passes the SSM storage provider key, so consumers need no new input. Deregistration disabled or no key keeps the previous policy. Builds on github-aws-runners#5467 and the earlier attempt in github-aws-runners#5274. Signed-off-by: Brend Smits <[email protected]>
Brend-Smits
added a commit
that referenced
this pull request
Oct 29, 2026
…#5562) ## Description The termination-watcher Lambdas (notification, handler and deregister-retry) read the GitHub App credentials from SSM to deregister runners. If those parameters are SecureStrings encrypted with a customer-managed KMS key, the roles have no `kms:Decrypt` on it, so the read fails and the runner is never deregistered. #5467 fixed the SSM actions and parameter list, so this is the next thing that breaks. This adds an optional `github_app_kms_key_arn` to the watcher config. When it is set and deregistration is enabled, all three roles get `kms:Decrypt` on that key. The SSM and KMS statements are built once and shared by the three roles. `multi-runner` passes the SSM storage provider key and the root module passes `kms_key_arn`, so nobody has to change their inputs. Without a key, or with deregistration off, the policy is the same as before. Prior attempt in #5274, which is no longer active. It also changed how environment variables are preserved, which I left out here to keep this to the KMS access. ## Test Plan - New `modules/termination-watcher/tests/kms.tftest.hcl`: key set (SSM actions on all primary, additional-app and manifest ARNs plus `kms:Decrypt` on only that key), no key, single app, deregistration disabled with a key set, and a key that is only known after apply. - `terraform test` in `modules/termination-watcher` and `modules/multi-runner`, `terraform validate` in both and at the root, `terraform fmt -check -recursive`. - `yarn test`, `yarn lint` and `yarn format-check` in `lambdas`. - Not deployed anywhere yet. ## Related Issues Builds on #5467. Supersedes the KMS part of #5274. --------- Signed-off-by: Brend Smits <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
guicaulada
pushed a commit
that referenced
this pull request
Nov 3, 2026
🤖 I have created a release *beep* *boop* --- ## [8.1.0](v8.0.0...v8.1.0) (2026-10-29) ### Features * add stateless registration cleanup with multi-App support ([#5465](#5465)) ([5959d43](5959d43)) * **termination-watcher:** support additional GitHub Apps ([#5467](#5467)) ([eefcb1e](eefcb1e)) ### Bug Fixes * **lambda:** bump undici from 6.29.0 to 6.29.1 in /lambdas ([#5554](#5554)) ([94f46c7](94f46c7)) * **scale-down:** clean EC2 runners incrementally and isolate failures ([#5463](#5463)) ([60a4c66](60a4c66)) * **scale-down:** scope cached clients by selected GitHub App ([#5466](#5466)) ([bbd92fe](bbd92fe)) * **termination-watcher:** grant kms:Decrypt for GitHub App parameters ([#5562](#5562)) ([7b54664](7b54664)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: runners-releaser[bot] <194412594+runners-releaser[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Termination-watcher deregistration currently uses only the first GitHub App credential, and its Terraform wiring omits the additional-App manifest. Configured additional Apps therefore cannot contribute quota to termination cleanup or its SQS retry path.
Load all credentials through the existing manifest-backed store. Select an App using observed installation quota, skip Apps in a one-minute throttling cooldown when another is available, and use a random initial offset for unknown quotas. Keep App JWT and installation-token authentication paired, resolve installation access for the requested owner, and try another configured App if authentication fails. Each termination or retry operation selects an App; authenticated-operation failures retain existing error handling. Single-App configurations remain supported.
Pass the optional manifest reference and credential parameter ARNs through termination-watcher Terraform, including automatic forwarding from multi-runner. Grant scoped
GetParameteraccess for the manifest andGetParametersaccess for batched credential reads. Omit the optional environment key when no manifest is configured. Deregistration retries retain the configured GHES endpoint.Validation: 52 termination-watcher package tests and three mocked Terraform tests pass. Coverage includes additional-App deregistration, paired credentials, quota exhaustion, secondary-limit cooldown, authentication fallback, manifest/IAM wiring, disabled deregistration, and single-App defaults. Runtime TypeScript, ESLint, Prettier, Terraform formatting, generated documentation, Lambda bundle build, and diff checks pass. No live GitHub/AWS changes were performed. TFLint is unavailable locally; existing package-wide coverage thresholds remain unchanged.
This PR targets main and changes only termination-watcher authentication, configuration, permissions, and retries.