Skip to content

feat(repos): report the drift of onboarded repositories nightly - #6816

Merged
dan-petty merged 8 commits into
mainfrom
feat/6783-repos-onboard-drift-job
Nov 23, 2026
Merged

dan-petty merged 8 commits into
mainfrom
feat/6783-repos-onboard-drift-job

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

CronJob repos-drift runs devops repos onboard --all --plan each night in the runner image (ADR 0035). Its pod acts as the Service App, and the new setting service.github_app.read_only makes each token ask for CONST_GITHUB_APP_READ_TOKEN_PERMISSIONS only. The ConfigMap does not carry the setting.

Row 0 sends no GET /user for the App: GitHub refuses that request to an installation token, and the error stopped the run.

--all --plan sets the gauge devops_cli_repos_drift_rows of each repository: state="drift" counts the rows off the baseline and state="not_readable" the rows that the check could not read. The command prints one state line for each repository. The rule group repos-drift warns on drift, on a not readable row and on a check that stops. A not readable row is its own state.

Closes #6783

Change: openspec/changes/archive/2026-11-23-6783-repos-onboard-drift-job/

@dan-petty dan-petty added type/feature Type feature: a new function scope/repos The devops repos commands and worktrees labels Nov 23, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Person steps

  1. After the merge, let Argo CD sync Application devops (CronJob repos-drift) and Application prometheus (the rule group repos-drift). Without Argo CD: devops k8s deploy-stack --stack devops from a clean checkout of origin/main.
  2. Start one run now: kubectl -n devops create job --from=cronjob/repos-drift repos-drift-manual, then read kubectl -n devops logs job/repos-drift-manual. The log holds one report and one Drift check of <repo>: ... line for each repository of service.repos.
  3. Confirm the series in Prometheus: devops_cli_repos_drift_rows{job="repos-drift"}, two series for each repository.

No Secret change is necessary: the pod reads the existing key DEVOPS_CLI_SERVICE_GITHUB_APP_PRIVATE_KEY of Secret devops-cli. The App already has read on each repository permission (ADR 0015), so the installation grants each permission of the read set.

Expected first result

The runner image has no copier yet (dan-petty/devtools pull request 43 is open). So rows 2, 3, 5, 6, 9, 10 and 11 are not readable with the person step that installs copier, and RepositorySettingsUnreadable fires for each repository each night. It stops after pull request 43 merges, devtools releases, and Renovate updates the FROM ghcr.io/dan-petty/devtools pin of the Dockerfile.

Review points for the owner

  • Report. A gauge and three warning alerts, not an issue. The SRE guideline makes a cause a ticket (a warning alert with a runbook row, routed to issues by Alertmanager), and a read-only token cannot write an issue.
  • Identity. The pod holds the Service App key, as each Job of the Service does, and DEVOPS_CLI_SERVICE_GITHUB_APP_READ_ONLY=true makes each token ask for read permissions only. The key itself can still mint a write token. A split as in CronJob renovate (an init container that writes only the token) needs a token-file input for the devops process, which does not exist. I did not build it, because the pod runs no program of a repository. Say if you want it as a follow-up.
  • Not verified until the first run. I did not find a GitHub page that says whether GET /repos/<repo> gives the merge settings (allow_squash_merge and the others) to an installation token with Administration read. If GitHub leaves them out, row 2 shows pending changes for them, and that is a false drift. Compare with devops repos onboard <repo> --plan with your own login.
  • Rows that the Job leaves out. Row 4 (GitHub needs Administration write for the GET of the Code Quality setup), row 12 (the webhook secret map, a secret value; feat(service): verify GitHub App webhooks with one secret #4417 deletes the row), row 13 (no live state with --all), rows 14 and 15. The ConfigMap has no github.release_app_client_id, so row 5 gives the person step of the variable and does not compare its value.
  • CI note. fix(docs): the error catalog lists the onboard errors #6815 (the error catalog lacks the four onboard errors) can fail tests/docs/test_exceptions.py::test_each_error_class_declares_the_codes_of_its_catalog_row in a shard where an onboard test runs first. This pull request adds tests to tests/commands/test_repos_onboard.py, so the shard layout changes.

The change 6783-repos-onboard-drift-job plans CronJob repos-drift, which runs
devops repos onboard --all --plan with a read-only App token, the gauge
devops_cli_repos_drift_rows and the rule group repos-drift.
devops repos onboard --all --plan sets the gauge devops_cli_repos_drift_rows of
each repository of service.repos, with one series for the rows off the
baseline and one for the rows that the check could not read, and prints the
state of each repository.
GitHub refuses GET /user to an installation token, and token_scopes raised on
the 403 before row 0, so a run as the App stopped. The App now sends no request
and row 0 notes that the token reports no OAuth scopes.
…ons only

The setting service.github_app.read_only (DEVOPS_CLI_SERVICE_GITHUB_APP_READ_ONLY)
makes the token request of the App ask for CONST_GITHUB_APP_READ_TOKEN_PERMISSIONS
only. The ConfigMap does not carry the setting.
CronJob repos-drift runs devops repos onboard --all --plan each night with a
read-only App token. The rule group repos-drift warns on a repository off its
baseline, on a row that the check could not read, and on a check that stops.
…ns in the pinned lists and the docs

The pinned variable lists of the config tests name DEVOPS_CLI_SERVICE_GITHUB_APP_READ_ONLY.
docs/CLUSTER.md names the Environments read and Secrets read permissions that the drift
Job's token asks for, and the full egress of the default perimeter. ADR 0015 records the
third, read-only token set.
@dan-petty
dan-petty force-pushed the feat/6783-repos-onboard-drift-job branch from daab00a to 566bf81 Compare November 23, 2026 00:38
@dan-petty
dan-petty marked this pull request as ready for review November 23, 2026 00:45
@dan-petty
dan-petty merged commit 7432f0f into main Nov 23, 2026
31 checks passed
@dan-petty
dan-petty deleted the feat/6783-repos-onboard-drift-job branch November 23, 2026 00:56
dan-petty pushed a commit that referenced this pull request Nov 23, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.197.0](v0.196.0...v0.197.0)
(2026-11-23)


### Features

* **repos:** report the drift of onboarded repositories nightly
([#6816](#6816))
([7432f0f](7432f0f))
* **roadmap:** Add toolsets for implement and review
([#6810](#6810))
([ec5b16b](ec5b16b))


### Bug Fixes

* **deps:** update container images
([#6817](#6817))
([fb349e5](fb349e5))
* **k8s:** start SearXNG when its metrics Secret is missing
([#6811](#6811))
([a11d112](a11d112))

---
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: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/repos The devops repos commands and worktrees type/feature Type feature: a new function

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(repos): report the drift of onboarded repositories nightly

1 participant