Repository navigation
Description
Problem or Motivation
The pod of the roadmap Service was OOMKilled (exit status 137) on 2026-11-08. It ran 2 h 39 min, then the kernel killed container service at its memory limit.
Facts from the cluster on 2026-11-08 (read only; the numbers below come from the report that led to this issue, and the manifest value was checked in the repository):
k8s/devops/roadmap-service/deployment.yaml: limit memory1Gi, limit cpu1, request memory256Mi. One replica, strategyRecreate.- Prometheus
container_memory_working_set_bytes, containerservice, namespacedevops. Pod A: 619, 778, 809, 863 and 855 MiB at 30-minute steps. Pod B (restarted by a ConfigMap change): 682, then 795 MiB. Pod C: 459, then 649 MiB. A new pod starts near 370 MiB. - The working set grows about 100 to 150 MiB each hour from a start of 370 to 460 MiB. It reaches 1Gi in 3 to 5 hours.
- Each earlier pod was replaced by a rollout before it reached the limit. This is the first OOM kill seen.
Nothing in k8s/monitoring/prometheus-values.yaml warns about this before the kill. RoadmapServiceRestarted fires only after the restart. The dashboard k8s-views-pods.json shows the working set, but no alert uses it.
Where the memory can grow (read from the code)
I did not find one proven cause. These are the candidates, most likely first, each with the line that holds the evidence.
- Answers kept by the GitHub session, bounded by count, not by size.
src/devops_cli/github/session_transport.py(line 272) keepsDEFAULT_GH_SESSION_ETAG_CACHE_SIZEanswers (64,src/devops_cli/config/defaults.pyline 766) in anLRUCache. The comment at line 763 says an answer can be a pull request diff. A diff has no size bound, so 64 answers can hold hundreds of MiB. This gives a rise to a plateau, not a rise with no end. The Service uses one session for all lanes (src/devops_cli/github/session.py,get_github_session). - Heap fragmentation from three worker threads for each repository.
RepoWorker(src/devops_cli/server/service.pyline 428) runs one thread for each lane of each repository. Each round builds a newGitHubRoadmapStore(src/devops_cli/roadmap/run.py,service_job). The store reads every issue and pull request withstate=all(src/devops_cli/roadmap/stores/github_store.pyline 1109). The round frees this at its end, but the glibc allocator keeps one arena for each thread and may not return the pages to the system.Dockerfilesets noMALLOC_ARENA_MAX. This gives a slow rise of the resident set with no leak in Python. - An unbounded queue of export tasks.
Tracer._send_payload(src/devops_cli/telemetry/tracer.pyline 1317) submits each span and metric payload to aThreadPoolExecutorwith 2 workers and an unbounded queue. If the collector is slow, the queue holds every payload until it is sent. The send time out is 1 second (DEFAULT_OTEL_HTTP_TIMEOUT_SECONDS), so this needs a collector that is slow for hours. - Spans kept in memory.
_COMPLETED_SPANS_BUFFER(tracer.pyline 305) keeps the last 1000 spans. It is bounded by count. A span with large attributes or events is large. This is a plateau, not a rise with no end.
Checked and bounded (no growth): RequestBudget._sent (window of one hour), FailureLedger (one entry for each repository and job, causes capped by the limit), DeliveryLRUCache (an LRUCache with a capacity), RepoWorker._pending_counts (keys are source, event and action), GitHubRoadmapStore (built for each round and dropped), pooled HTTP clients (src/devops_cli/http/pool.py, keyed by transport).
Not verified:
- No heap snapshot or
tracemalloctrace of the running pod. All four candidates are from reading code. - The size of the answers in the session cache in the real pod.
- Whether the glibc arenas are the cause (needs
MALLOC_ARENA_MAX=2on a test pod, or a read of/proc/<pid>/smaps). - The health of the OTLP collector on 2026-11-08.
- Page cache from git fetches in the clones on the volume
home. The working set counts active file pages. The kernel reclaims them before an OOM kill, so this is unlikely to be the cause of the kill. - Metric label growth in
GLOBAL_METRICS: the labels I read (repo,lane,row,identity,provider,event,outcome) are all bounded.
Proposed Solution & Architectural Design
Find the cause with a measure. Do not raise the limit first.
- Write a test that runs the Service round N times with fakes (a fake store, a fake GitHub session, a fake exporter) and measures the growth of the heap with
tracemalloc. The repository has a profiler for this:devops_cli.telemetry.memory_profiler.MemoryProfileranddevops test profile-memory. The test fails when a named structure holds more entries or bytes after round N than after round 10. The named structures are the four above. - Fix what the measure shows. A bound by bytes for the session answers (for example, keep no answer above a size, or use
cachetoolswith agetsizeof). A cap on the export queue.MALLOC_ARENA_MAX=2in the container env only if the measure shows the arenas. - Add the alert
RoadmapServiceMemoryNearLimittok8s/monitoring/prometheus-values.yaml: the working set of containerserviceabove 85 percent of its limit for 10 minutes. The expression ismax 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. - A higher limit is a stopgap only. It is safe only while the node has free memory for the new limit, and it must come with the measure above, because a leak of 100 to 150 MiB each hour reaches any limit. If the owner wants it, set it in a separate change with the node's free memory in the text.
Acceptance criteria
-
uv run pytest tests/server/test_service_memory.py -qpasses. The test runs 200 rounds with fakes and fails if the session answers, the export queue or the span buffer grow without bound. Today the command fails: the file does not exist. -
uv run pytest tests/server/test_service_memory.py -q -k growth_is_boundedfails on a build where the named structure is made unbounded (the test proves it can fail). Today the command fails: the test does not exist. -
grep -q "RoadmapServiceMemoryNearLimit" k8s/monitoring/prometheus-values.yamlsucceeds. Today it fails: no rule covers the working set. -
uv run devops test profile-memory(or the new test) shows that the heap after round 200 is within a stated bound of the heap after round 10. The bound is in the test. Today no such check exists. - After the change, a pod that runs 6 hours has a working set that is flat in
container_memory_working_set_bytes(read in Grafana, in the pull request comment).
Target Subsystem
Service, Observability
Existing Tool Considered
tracemalloc(standard library) and the repository'sMemoryProfilerinsrc/devops_cli/telemetry/memory_profiler.py. They measure the heap growth. No new library is needed.kube_pod_container_resource_limitsandcontainer_memory_working_set_bytes(kube-state-metrics and cAdvisor, already scraped). They give the alert with no new code.cachetoolsis already a dependency (LRUCachein the session). Itsgetsizeofargument can bound a cache by bytes.
Cost
Estimate: about 120000 tokens to write the test and the fix and about 30000 to review and fix the checks. About 2 to 3 hours of elapsed time. The alert is one rule and one test, about 15000 tokens.
Related
- fix(roadmap): read the pod status to find an out-of-memory kill #3727 reads the pod status to find an out-of-memory kill. That issue is about the failure class of a runner Job, not about the Service pod. It is not a duplicate.
RoadmapServiceRestartedink8s/monitoring/prometheus-values.yamlfires after a restart. The new alert fires before it.
Proposed design
Problem statement
The roadmap Service pod was OOMKilled at its 1Gi memory limit on 2026-11-08 after 2 h 39 min. Its working set rises by about 100 to 150 MiB each hour from a start near 370 MiB. Two structures have no bound by bytes: the session keeps 64 GET answers, and the tracer queues export payloads with no cap. No alert warns before the kill. This change bounds both structures, sets the allocator arena limit, adds the alert and adds a test that measures the growth.
Acceptance criteria
Requirement: Session answers are bounded by bytes
The GitHub session SHALL keep its stored GET answers within DEFAULT_GH_SESSION_ETAG_CACHE_BYTES bytes and 64 answers.
Scenario: The stored answers pass the byte budget
- WHEN the session stores 64 answers of 4 MiB each, with the byte budget at 64 MiB
- THEN the stored answers hold at most 64 MiB in total, the least recently used answers are gone, and the next GET of a dropped URL carries no
If-None-Match
Requirement: An oversized answer is not stored
The session MUST return an answer that is larger than the whole byte budget and MUST NOT store it.
Scenario: One answer is larger than the budget
- WHEN a GET returns an answer of 128 MiB, with the byte budget at 64 MiB
- THEN the call returns the answer with no error, and the next GET of that URL carries no
If-None-Match
Requirement: The export queue is bounded
The tracer SHALL keep at most DEFAULT_OTEL_EXPORT_QUEUE_MAX_PAYLOADS payloads that wait for export, and SHALL count each payload that it drops.
Scenario: A slow collector fills the queue
- WHEN the exporter blocks and the tracer sends 1000 payloads, with the cap at 256
- THEN at most 256 payloads wait, 744 payloads are dropped, and the drop counter reads 744
Requirement: The memory test runs 200 rounds
The change SHALL add tests/server/test_service_memory.py, which runs the status lane's round 200 times with fakes and compares the heap at round 10 and at round 200.
Scenario: 200 rounds with a fake store, session and exporter
- WHEN
uv run pytest tests/server/test_service_memory.py -qruns - THEN each named structure holds at most its bound, and the traced heap grows by at most the stated bound between round 10 and round 200
Requirement: The growth check names a structure that grows
The growth check MUST report each structure whose entries or bytes pass its bound between the two snapshots.
Scenario: One structure grows without a bound
- WHEN the check compares two snapshots in which one structure gains 1000 entries in each round
- THEN the check names that structure, and the test that gives it the snapshots fails
Requirement: The alert warns before the limit
k8s/monitoring/prometheus-values.yaml SHALL hold the rule RoadmapServiceMemoryNearLimit in the roadmap-service group.
Scenario: The rule is read from the values file
- WHEN a test reads the
roadmap-servicegroup - THEN the group holds
RoadmapServiceMemoryNearLimitwith severitywarning,for: 10m, and an expression that dividescontainer_memory_working_set_bytesbykube_pod_container_resource_limits{resource="memory"}for containerservice
Requirement: The alert has a runbook step
The Roadmap service section of k8s/README.md SHALL name RoadmapServiceMemoryNearLimit and its step.
Scenario: The runbook names the new alert
- WHEN a test reads the Roadmap service section of
k8s/README.md - THEN the section names
RoadmapServiceMemoryNearLimitand tells the reader to read the working set of the pod and the drop counter
Requirement: The pod sets the arena limit
Container service of k8s/devops/roadmap-service/deployment.yaml SHALL set MALLOC_ARENA_MAX to 2.
Scenario: The Deployment env is read
- WHEN a test reads the env of container
service - THEN the env holds
MALLOC_ARENA_MAXwith the value2
Requirement: ADR 0006 records the byte budget
ADR 0006 SHALL record that the session bounds its stored answers by bytes and by count.
Scenario: The ADR is read
- WHEN a test reads
docs/adr/0006-github-session-requests-go-through-gidgethub.md - THEN the text names the byte budget and
DEFAULT_GH_SESSION_ETAG_CACHE_BYTES
Existing Tool Considered
No alternatives check has run on this issue. tracemalloc in the Python standard library measures the heap growth of the fakes, and the change adds no new dependency; it gives no bound of its own, so the test states the bound of each structure. cachetools is already a dependency, and its LRUCache takes getsizeof with a maxsize in bytes; it raises ValueError for one entry larger than maxsize, so the change adds that guard. kube-state-metrics and cAdvisor already give kube_pod_container_resource_limits and container_memory_working_set_bytes; no rule reads them for this pod, so the change adds the rule. pytest-memray was compared and rejected, because it bounds the peak of a test and does not compare one structure between two rounds.
Key questions
- What bounds the session's stored GET answers today?:
SessionGitHubAPI.__init__keeps each GET answer in acachetools.LRUCachewithmaxsize=DEFAULT_GH_SESSION_ETAG_CACHE_SIZE, 64 answers, and no bound by bytes. An answer can be a pull request diff, and GitHub sets no size on a diff. ADR 0006 records the count. [sources: src/devops_cli/github/session_transport.py:272, src/devops_cli/config/defaults.py:766, docs/adr/0006-github-session-requests-go-through-gidgethub.md] - How does the session bound its stored answers?: Keep 64 answers and add a byte budget of
DEFAULT_GH_SESSION_ETAG_CACHE_BYTES(64 MiB) withLRUCache(maxsize=..., getsizeof=...), so the least recently used answers leave until the stored bytes fit. The size of one answer is the length of its stored strings and bytes, and the length of the compact JSON text of a decoded body. An answer larger than the whole budget is not stored, and the call returns its answer. (best practice) [sources: src/devops_cli/github/session_transport.py:272, docs/adr/0006-github-session-requests-go-through-gidgethub.md]- Chosen: Byte budget with
getsizeof.cachetoolsalready holds the answers and takesgetsizeof, so one argument adds the byte bound and the LRU order stays. - Rejected: Drop answers above a fixed size. An answer just under the size still adds up, and the count stays the only real bound.
- Rejected: Keep the count of 64 only. 64 diffs can hold hundreds of MiB, as the issue and ADR 0006 record.
- Chosen: Byte budget with
- How does the tracer bound the payloads that wait for export?: The tracer keeps at most
DEFAULT_OTEL_EXPORT_QUEUE_MAX_PAYLOADS(256) payloads in a bounded queue that two worker threads drain. A payload that finds the queue full is dropped, and a counter records each drop. (best practice) [sources: src/devops_cli/telemetry/tracer.py, src/devops_cli/config/defaults.py:295]- Chosen: Bounded queue with a drop counter. It bounds the memory of a slow collector and it makes each drop visible in the Service's metrics.
- Rejected: More exporter threads. Two threads drain a payload within the 1 s timeout, and more threads do not bound a collector that is slow for hours.
- Rejected: Keep the unbounded executor queue. A slow collector then holds every payload in memory with no limit.
- Does the Deployment set
MALLOC_ARENA_MAX?: Yes. SetMALLOC_ARENA_MAX=2in the env of containerservice. One process runs one thread for each lane of each repository, glibc gives each thread its own arena, and the observed working set rises with no plateau. The setting is bounded, it needs no new image, and the deferred 6-hour check verifies it. (best practice) [sources: k8s/devops/roadmap-service/deployment.yaml, src/devops_cli/server/service.py]- Chosen: Set
MALLOC_ARENA_MAX=2in the Deployment env now. It lowers the resident set of a threaded process, it is one env value, and a revert is one line. - Rejected: Wait for a read of
/proc/<pid>/smapson a test pod. The read needs a deployed pod and hours of run, so the item could not reach Ready; the deferred check covers it. - Rejected: Rebuild the image with the variable. The env of the Deployment changes the pod, and the image build stays as it is.
- Chosen: Set
- Which of the four candidate structures are already bounded?:
_COMPLETED_SPANS_BUFFERis adequewithmaxlen=DEFAULT_SPAN_BUFFER_MAX_SPANS, 1000 spans.RequestBudget._sentholds one hour of requests.FailureLedgerkeeps one entry for each repository and job, with at most its limit of causes.RepoWorker._pending_countskeys are source, event and action. These four need no change. [sources: src/devops_cli/telemetry/tracer.py, src/devops_cli/config/defaults.py, src/devops_cli/server/service.py, src/devops_cli/roadmap/run.py] - What does the memory test measure, and where does it live?:
tests/server/test_service_memory.pyruns the status lane's round 200 times with a fake store, a fake session and a fake exporter. It takes atracemallocsnapshot at round 10 and at round 200. A pure check compares the entries and bytes of each named structure between the two snapshots and reports each structure that grew past its bound. (best practice) [sources: tests/server/test_server_service.py, src/devops_cli/roadmap/run.py]- Chosen:
tracemallocin a pytest test with fakes. It is in the standard library, it names the allocation site, and it runs offline in CI. - Rejected:
pytest-memray. It bounds the peak memory of a test, and it does not compare one named structure between two rounds. - Rejected:
devops test profile-memoryagainst the pod. It needs a running pod and hours of run, so it is no offline check of a pull request.
- Chosen:
- Which threshold and window does the new alert use?: The rule fires when the working set of container
serviceis above 85% of its memory limit for 10 minutes, with severitywarning, in theroadmap-servicegroup. At the measured growth, 85% leaves about one hour of warning before the limit. (best practice) [sources: k8s/monitoring/prometheus-values.yaml, k8s/devops/roadmap-service/deployment.yaml]- Chosen: 85% for 10 minutes, warning. It leaves about an hour of headroom, and the other rules of the group wait 10 minutes.
- Rejected: 95% for 5 minutes. At 50 MiB of headroom it leaves under 30 minutes of warning.
- Rejected: An absolute value in MiB. kube-state-metrics reports the limit, so a ratio follows a change of the limit and an absolute value does not.
- Does this change raise the memory limit of the Service?: No. The limit stays
1Gi. One pod reached 863 MiB and did not die, so a higher limit moves the plateau, and the growth reaches any limit. The byte bound and the arena setting lower the plateau, and the alert gives the lead time. (best practice) [sources: k8s/devops/roadmap-service/deployment.yaml]- Chosen: Keep the limit at
1Gi. The bound of each structure lowers the plateau, and the alert warns before the limit. - Rejected: Raise the limit to
2Ginow. It needs free memory on the node and it hides the growth; the owner asks for it in a separate change.
- Chosen: Keep the limit at
- What does the alert group require of a new rule?: The spec
roadmap-service-alertsrequires that the roadmap Service has its own alert group and that each alert points to its runbook step. Each rule of the group ends its description with(k8s/README.md, Roadmap service). [sources: openspec/specs/roadmap-service-alerts/spec.md, k8s/monitoring/prometheus-values.yaml]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 8, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(service)scope of the title gives the scope.A production service is killed after hours, causing downtime, and no alert fires before the kill.The roadmap-service is unavailable when OOMKilled, directly impacting users who depend on it.Four candidate causes are listed but none is confirmed; diagnosis and fix may span config, code, and runtime tuning.Both are OOMKilled devops-cli pods in k8s, but #2806 targets a one-off spike in a runner Job while this candidate targets gradual memory growth in the long-running roadmap-service.devops-cli-service commentedon Nov 8, 2026
Status set to Ready at d3770f5 (see proposed design in issue body).
Moved to new items: #4125.
devops-cli-service commentedon Nov 8, 2026
Released in v0.88.1: https://github.com/dan-petty/devops-cli/releases/tag/v0.88.1
devops-cli-service commentedon Nov 8, 2026
Live since 2026-11-08 12:49 UTC