Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The process's GitHub session (#767) sends its own REST requests through gidgethu
- **Retries.** gidgethub's `handle_rate_limit_error` hook retries a rate limit (a 403 with no quota left, a 429, or a 403 with `retry-after`) up to `DEFAULT_GH_MAX_RETRIES` times, waiting what `run_gh` would: the Retry-After, else until the quota resets, else jittered backoff from the secondary-limit floor. A 5xx is retried only for a read, from `DEFAULT_GH_SERVER_ERROR_RETRY_FLOOR_SECONDS`, since GitHub may have applied a write it failed to answer. The session's `_request` sends a GET again when its connection is lost before its answer is read. The errors are `httpx2.RemoteProtocolError`, `httpx2.ReadError` and `httpx2.WriteError`. It sends the GET at most `DEFAULT_GH_MAX_RETRIES` more times, after the same ledger wait. It does not send a lost write again. Each gidgethub attempt keeps its own budget, so one GET sends at most nine requests (#3506). The session does not retry a refused connect, a connect or read timeout, or a refused origin.
- **Errors.** `github/error_classifier.py` maps gidgethub's exceptions by type, status and headers, never by message text, onto `GitHubUnauthenticatedError` (401), `GitHubScopeError` (a 403 whose `x-accepted-oauth-scopes` the token holds none of), `GitHubRateLimitError`, `GitHubNotFoundError` (404) and `GitHubUnreadError` (no readable answer, an answer that does not decode, or a request a close stopped). Anything else is a plain `GitHubOperationError`. Each carries the status, as an int, and the request path. Only a `DevOpsCLIError` leaves `rest()`: one of these, or one raised on the way, such as the egress check's `SSRFBlockedError`, unchanged.
- **Pagination.** `paginate(path, *, iterable_key=None)` reads a REST listing one page per portal call, as its consumer asks for items, and follows the `rel="next"` link gidgethub reads from each page's `Link` header, whether it names a page number or a cursor. Every page passes through the same pacing, retries, origin hook and error classes as `rest()`. It does not use gidgethub's `getiter`, which iterates whatever a page decodes to: a string's characters, or an object's keys when its key is missing. A page must be a JSON array, or an object holding one under `iterable_key`. Anything else raises `GitHubUnreadError` naming the endpoint and the page, so a listing never ends short without saying so (#1034's rule). An empty array, or a page without a next link, ends the listing. A listing still linking a next page after `DEFAULT_GH_MAX_PAGINATED_PAGES` pages, the cap every other paginated reader keeps, raises `GitHubUnreadError` naming the endpoint and the cap.
- **Conditional requests.** gidgethub's `cache=` holds each GET's answer with its ETag in a `cachetools.LRUCache` of `DEFAULT_GH_SESSION_ETAG_CACHE_SIZE` answers, in memory, built by each session's transport, so one identity's ETags are never sent as another's and a close drops them. The next GET of that URL carries `If-None-Match`, and a 304 gives back the stored answer as a copy, so no caller changes what a later 304 returns. Every attempt, a 304 too, is paced and charged, and the ledger takes the quota the 304 reports, which GitHub leaves unspent. A stored page passes the same page check as a fresh one. GitHub's ETag covers a page's body only and its 304 carries no `Link` header (checked 2026-10-19), so a full last page that gains a next page keeps its ETag. A page that links no next page is therefore read in full and not kept, which leaves the store to the pages that can answer 304.
- **Conditional requests.** gidgethub's `cache=` holds each GET's answer with its ETag in a `cachetools.LRUCache` of at most `DEFAULT_GH_SESSION_ETAG_CACHE_SIZE` answers and `DEFAULT_GH_SESSION_ETAG_CACHE_BYTES` bytes, in memory (#4116: a diff has no size bound, so the count alone did not bound the memory; an answer above the whole byte budget is returned and not stored), built by each session's transport, so one identity's ETags are never sent as another's and a close drops them. The next GET of that URL carries `If-None-Match`, and a 304 gives back the stored answer as a copy, so no caller changes what a later 304 returns. Every attempt, a 304 too, is paced and charged, and the ledger takes the quota the 304 reports, which GitHub leaves unspent. A stored page passes the same page check as a fresh one. GitHub's ETag covers a page's body only and its 304 carries no `Link` header (checked 2026-10-19), so a full last page that gains a next page keeps its ETag. A page that links no next page is therefore read in full and not kept, which leaves the store to the pages that can answer 304.
- **Identity.** The requests carry `CONST_GITHUB_USER_AGENT` and `CONST_GITHUB_API_VERSION`. They never carry the login or an email.

## Considered Options
Expand Down
3 changes: 2 additions & 1 deletion k8s/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ Alertmanager runs from the prometheus chart (`alertmanager` in `monitoring/prome
| `ResearchCriticalFindings` | The last `devops research sweep` of the last 7 days found a critical advisory that affects a pin of the project (#3899). The sweep sets zero for a severity with no finding, so a clean sweep ends the alert. A sweep with a lookup that got no answer sets no value | — | critical | Read the candidates that the sweep filed, or run `devops research advisories`, and update the pin. Run the sweep again. |
| `RoadmapServiceIdentityRefused`, `RoadmapServiceGitHubThrottled` | GitHub refused the identity of the roadmap Service, or throttled its requests; see Roadmap service, Alerts | — | critical |
| `RoadmapServiceJobsFailing` | All jobs of one row of a repository failed in 1 hour | 30m | warning |
| `RoadmapServiceLaneStalled`, `RoadmapServiceRestarted`, `RoadmapServiceUnavailable`, `RoadmapServiceGitHubRequestsHigh`, `RoadmapServiceModelRequestsHigh`, `RoadmapServiceStateUnkept` | The roadmap Service stalls, its pod restarts or is unavailable, its GitHub or model requests in an hour are high, or it could not write a state record; see Roadmap service, Alerts | 0–15m | warning |
| `RoadmapServiceLaneStalled`, `RoadmapServiceRestarted`, `RoadmapServiceMemoryNearLimit`, `RoadmapServiceUnavailable`, `RoadmapServiceGitHubRequestsHigh`, `RoadmapServiceModelRequestsHigh`, `RoadmapServiceStateUnkept` | The roadmap Service stalls, its pod restarts, uses almost all of its memory limit or is unavailable, its GitHub or model requests in an hour are high, or it could not write a state record; see Roadmap service, Alerts | 0–15m | warning |
| `RoadmapServiceWebhooksRejected` | The webhook route of the roadmap Service rejected more than 20 deliveries in 15 minutes; see Roadmap service, Alerts | — | warning |
| `ClusterMetricsMissing` | `kube_node_status_condition` is absent, so the node rules cannot fire | 10m | critical |
| `PrometheusConfigReloadFailed`, `PrometheusRuleEvaluationFailures`, `PrometheusNotConnectedToAlertmanager`, `PrometheusDroppingAlerts`, `PrometheusCompactionsFailing` | Prometheus's own health | 0–15m | warning |
Expand Down Expand Up @@ -736,6 +736,7 @@ The rule group `roadmap-service` in `monitoring/prometheus-values.yaml` watches
| `RoadmapServiceJobsFailing` | All jobs of one row of a repository failed in 1 hour (increase in errors is greater than zero, and increase in successes is zero). A success of another row of the lane does not clear the alert. | 30m | warning | Read the errors of that repository in the Service log: `kubectl -n devops logs deployment/roadmap-service`. The log line of a failed round names its rows. Repair the cause, for example the repository's `.github/roadmap.toml`. |
| `RoadmapServiceLaneStalled` | No job of a repository and lane started in 2 hours while the deployment has an available replica. In a new pod, the 2 hours start when the worker of the lane starts. | 10m | warning | Find in the Service log a pause of the rounds, a spent request budget, or a job that does not end. If a job does not end, restart the deployment. |
| `RoadmapServiceRestarted` | The `service` container restarted in the last hour | — | warning | Read the log before the restart: `kubectl -n devops logs deployment/roadmap-service --previous`. |
| `RoadmapServiceMemoryNearLimit` | The working set of the `service` container is above 85% of its memory limit for 10 minutes (#4116). The kernel kills the container at 100%, and `RoadmapServiceRestarted` fires only after that. | 10m | warning | Read the working set: `kubectl -n devops top pod`. Search the Service log for `The OTel export queue is full`: it shows a collector that does not answer, and the tracer drops payloads then. Then read the Service log for the rounds of the last hours. A rise of the limit only delays the kill. |
| `RoadmapServiceUnavailable` | The deployment has an unavailable replica. A rollout stops the old pod before it starts the new one, so the rule waits 10 minutes. | 10m | warning | Read the events: `kubectl -n devops describe deployment/roadmap-service` and `kubectl -n devops get events --sort-by=.lastTimestamp`. |
| `RoadmapServiceGitHubRequestsHigh` | The Service sent more GitHub requests in 1 hour, not counting answers with status 304, than 90% of the budget it reports in `devops_cli_service_budget_limit_requests` (`service.github_requests_per_hour`, 500 by default) | — | warning | Set the variable `Job` of the `devops-cli Telemetry` dashboard to `roadmap-service`, read the GitHub Requests by Resource panel, and find the repository in the Service log. If the requests are expected, raise the budget with `devops config set service.github_requests_per_hour <n>`. Otherwise, remove the repository from `service.repos`. Then run `devops k8s deploy-stack --stack devops`. |
| `RoadmapServiceModelRequestsHigh` | The Service sent more than 352 model requests in 1 hour. A request that the cache answered does not count. | — | warning | Find the model on the `AI Spend & LLM Usage Telemetry` dashboard, and the repository in the Service log. Remove the repository from `service.repos` until the cause is known, then run `devops k8s deploy-stack --stack devops`. |
Expand Down
15 changes: 15 additions & 0 deletions k8s/monitoring/prometheus-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,21 @@ serverFiles:
annotations:
summary: "The roadmap Service container in {{ $labels.pod }} restarted"
description: 'The restart count of container {{ $labels.container }} of pod {{ $labels.namespace }}/{{ $labels.pod }} increased by {{ printf "%.0f" $value }} in the last hour (k8s/README.md, Roadmap service).'
# The kernel kills the container at its memory limit, and RoadmapServiceRestarted fires
# only after that. The working set grew 100 to 150 MiB each hour before the kill (#4116).
# The two series come from the kubelet and kube-state-metrics, so max by drops their
# other labels and the division matches on namespace and pod.
- alert: RoadmapServiceMemoryNearLimit
expr: >-
max by (namespace, pod) (container_memory_working_set_bytes{namespace="devops", pod=~"roadmap-service-.+", container="service"})
/ max by (namespace, pod) (kube_pod_container_resource_limits{namespace="devops", pod=~"roadmap-service-.+", container="service", resource="memory"})
> 0.85
for: 10m
labels:
severity: warning
annotations:
summary: 'The roadmap Service container in {{ $labels.pod }} uses {{ $value | humanizePercentage }} of its memory limit'
description: 'The working set of container service of pod {{ $labels.namespace }}/{{ $labels.pod }} has been above 85% of its memory limit for 10 minutes, and the kernel kills the container at 100% (k8s/README.md, Roadmap service).'
# The Recreate strategy stops the old pod before it starts the new one, so a rollout
# has no available replica for a few minutes.
- alert: RoadmapServiceUnavailable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-11-08
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Design

## Context

The Service runs one worker for each lane of each repository in one process. They share the one GitHub session (`get_github_session`) and the one tracer. The session stores GET answers in an `LRUCache` for its next conditional GET. The tracer sends each payload to two export threads.

## Decisions

- **The session store is bounded by bytes and by count.** `LRUCache(maxsize=DEFAULT_GH_SESSION_ETAG_CACHE_BYTES, getsizeof=<size of one stored answer>)`, with the count bound kept. The size of an answer is the length of its text or bytes body, or of its encoded JSON for a decoded value. The size is counted once, when the answer is stored. An answer above the whole budget is returned and not stored, because `LRUCache` raises `ValueError` for it. The default budget is 64 MiB, a quarter of the memory request of the container.
- **The export queue is capped with a semaphore.** `_send_payload` takes a slot before it submits a payload, and the done callback of the future gives it back. When no slot is free, the payload is dropped and `export_dropped` grows by one. A drop is a counter and one warning log line at the first drop, and it is no error, because telemetry must not stop a command.
- **The alert reads cAdvisor and kube-state-metrics.** The expression is the one of the issue. It divides the working set by the limit for the container `service` of the pods of the roadmap Service, and it waits 10 minutes.
- **The test measures the heap with `MemoryProfiler`.** It compares the heap after round 10 with the heap after round 200 and names the allocation sites that grew.

## Rejected Alternatives

- **Raise the memory limit.** A rise of 100 to 150 MiB each hour reaches any limit. Rejected by the issue and by measure 1: the store has no bound by bytes.
- **Set `MALLOC_ARENA_MAX=2` in the Deployment.** Measure 4 kept the resident set flat with no setting, and it was higher with the setting. The change adds it only if a later measure of the pod shows fragmentation.
- **Drop the oldest payload when the export queue is full.** `ThreadPoolExecutor` has no API to remove a queued item, so this needs a home-grown queue. Dropping the newest payload needs one semaphore.
- **`pytest-memray`.** It bounds the peak of a test and does not compare two rounds.
Loading
Loading