fix(orb): stale-token grace when the broker mint blips in broker mode - #1463
Merged
Conversation
A brokered self-host holds no GitHub App key, so a single Orb token-mint failure was fatal — the review failed (→ retry/DLQ) and an Orb blip during the re-mint window stalled the fleet. createInstallationToken now catches a broker mint failure and, if the cached installation token is STILL within its real expiry, serves it (a valid token beats a stalled review; an actually-expired token is never reused). A genuine outage with no usable cached token emits an alertable structured log (orb_broker_unavailable) and rethrows so the queue's retry/DLQ handles it.
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1463 +/- ##
=======================================
Coverage 95.44% 95.44%
=======================================
Files 194 194
Lines 21064 21070 +6
Branches 7623 7624 +1
=======================================
+ Hits 20104 20110 +6
Misses 383 383
Partials 577 577
🚀 New features to boost your workflow:
|
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.
Summary
In broker mode a self-host holds no GitHub App key, so a single Orb token-mint failure was fatal —
the review failed (→ retry/DLQ) and an Orb blip during the re-mint window stalled the whole fleet
(broker-client.ts: "a mint failure is fatal for that request").
createInstallationTokennow wraps the broker mint in stale-token grace: on a mint failure, if the cachedinstallation token is still within its real expiry, it serves that token — a valid token beats a stalled
review. Tokens re-mint only in their last 2 minutes, so this rescues the common case (a transient Orb blip /
deploy / rate-limit during re-mint) without ever reusing an actually-expired token. A genuine outage with no
usable cached token emits an alertable
orb_broker_unavailablelog and rethrows, so the queue's existingretry/DLQ still handles a sustained outage.
Scope
src/github/app.ts+ its test; cloud (no enrollment secret) is byte-identical — the branch is broker-only.Validation
npm run typechecknpm run test:coverage— full suite green; 100% changed lines + branches (grace serves cached; no-cache rethrows; expired-cache rethrows).Roadmap item #2 (broker-mode availability). A full open-circuit cooldown is a possible follow-up, but the queue's exponential backoff already throttles retries to a down Orb.