Skip to content

fix(scale-down): reselect GitHub Apps and attribute cleanup quota - #5466

Open
guicaulada wants to merge 1 commit into
mainfrom
gc/fix/scale-down-multi-app-cleanup
Open

guicaulada wants to merge 1 commit into
mainfrom
gc/fix/scale-down-multi-app-cleanup

Conversation

@guicaulada

@guicaulada guicaulada commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Scale-down caches an installation client by owner, so an invocation can keep using the first selected GitHub App even when additional Apps have available quota. Its runner-state response metrics also omit the selected App index and attribute quota to the primary App.

Re-evaluate App selection before cache lookup and key installation clients by App, runner type, and owner. Attach a response hook that reports quota and metrics for the App making each request, including paginated lookups and deletion. Subsequent cleanup operations can select another configured App while retaining client reuse within the correct scope.

Validation: 353 control-plane tests pass, including selection changes for the same owner, client reuse, and correct App attribution. Runtime TypeScript, ESLint, Prettier, Lambda bundle build, and diff checks pass. No live GitHub/AWS changes were performed.

This PR targets main and contains only client-selection and quota-attribution changes.

@guicaulada
guicaulada requested a review from a team as a code owner September 23, 2026 14:26
@guicaulada
guicaulada added this pull request to stack #5468 September 23, 2026 14:28
@guicaulada
guicaulada force-pushed the gc/fix/scale-down-multi-app-cleanup branch from c404f77 to 576ac85 Compare September 23, 2026 14:36
@guicaulada
guicaulada removed this pull request from stack #5468 September 23, 2026 14:39
@guicaulada
guicaulada changed the base branch from gc/fix/orphan-cleanup to main September 23, 2026 14:39
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Quota attribution is missing for pre-installation lookups and failed GitHub requests.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 Medium severity

Open (2)
What changed in this PR

Updates scale-down GitHub App selection, client caching, and quota attribution for multi-App cleanup workflows.

Changes:

  • Re-selects Apps before cache lookup and scopes clients by App, runner type, and owner.
  • Adds App-specific quota instrumentation.
  • Adds tests for App reselection, client reuse, and attribution.
File Summary
lambdas/​functions/​control-plane/​src/​scale-runners/​scale-down.ts Updates client selection, caching, and quota hooks.
lambdas/​functions/​control-plane/​src/​scale-runners/​scale-down.test.ts Tests multi-App selection and quota attribution.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +57 to +59
octokit.hook.after('request', async (response) => {
await metricGitHubAppRateLimit(response.headers, appIdx);
});
Comment on lines +57 to +59
octokit.hook.after('request', async (response) => {
await metricGitHubAppRateLimit(response.headers, appIdx);
});

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants