fix(selfhost): sync brokered self-host installed-repo list from GitHub - #5033
Merged
Conversation
The central Orb relay deliberately does not forward installation/ installation_repositories webhook events to brokered self-host containers, so a brokered instance only ever learns about a repo the first time a forwarded PR/issue event arrives for it -- a freshly enrolled, quiet repo has no local repositories row at all. Add an hourly, broker-mode-only sync that fetches the live installation repo list directly via the broker token (GET /installation/repositories) and keeps isInstalled in sync, including flipping a removed repo back to false. No-op everywhere else (cloud, non-brokered self-host). Fixes #5028, part of the isRegistered/isInstalled untangling epic (#5016).
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 #5033 +/- ##
=======================================
Coverage 94.36% 94.36%
=======================================
Files 458 459 +1
Lines 39255 39285 +30
Branches 14322 14329 +7
=======================================
+ Hits 37042 37072 +30
Misses 1558 1558
Partials 655 655
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 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
syncBrokeredInstalledRepos(src/orb/installed-repos-sync.ts), an hourly self-host job that fetches a brokered installation's live repo list directly from GitHub (GET /installation/repositories, using the broker-minted token) and upsertsrepositories.isInstalledaccordingly — flipping a repo back toisInstalled: falseonce GitHub stops returning it.status: "skipped") outside broker mode (ORB_ENROLLMENT_SECRETunset) — cloud and non-brokered self-host are byte-identical.Why
Fixes #5028 (part of the isRegistered/isInstalled untangling epic, #5016). The central Orb relay deliberately does not forward
installation/installation_repositorieswebhook events to brokered self-host containers (the container runs under the CENTRAL Orb App, not its own — forwarding those would let it mistake the central app's install state for its own). Without this, a brokered self-host'srepositories.isInstalledonly populates lazily, the first time a forwarded PR/issue event arrives for a repo — a freshly enrolled, quiet repo has no local row at all, and every core feature this epic is migrating ontoisInstalled(signal snapshots, fidelity repair, the open-data backfill, etc.) would silently skip it. This is a prerequisite for the rest of the epic's sub-issues.Scope
CONTRIBUTING.md.Closes #NNNNsense — maintainer PR, not a contributor PR; closes epic sub-issue BLOCKING: Fix isInstalled population for brokered self-host #5028 directly (see Notes).Validation
git diff --checknpm run typechecknpm run test:coverage(full, unsharded) — 100% branch coverage oninstalled-repos-sync.ts; the newdb/repositories.tshelper and every wiring point exercised via dedicated + smoke tests.npm run test:ci(full local gate)npm audit --audit-level=moderate— cleanSafety
reasonstring (HTTP status or a bounded error message) surfaces on failure.fetchBrokeredInstallationToken) unmodified.MAINTENANCE_JOB_TYPESandGITHUB_BUDGET_BACKGROUND_TYPESboth updated so the new job participates correctly in the self-host maintenance-trickle and GitHub-rate-limit-yielding policies.Known limitation (flagged, not blocking)
The generic per-message GitHub rate-limit admission check (
githubRateLimitAdmissionKeyForJob) can't resolve an installation-scoped key for this job type, because the installationId isn't known until the broker exchange happens at execution time (not at dispatch time). The job is still correctly marked as a GitHub-budget consumer (GITHUB_BUDGET_BACKGROUND_TYPES) for classification/metrics purposes, but doesn't get pre-emptive per-installation admission gating the way repo-scoped jobs do. Given the low call volume (typically 1 request per hour, more only for large installations) and hourly cadence, this is an acceptable gap rather than something to force through a synthetic message field.Notes
isInstalled, the direct fix for the original queue-growth report) is next.