Repository navigation
Description
User Story
I run OpenShell on Kubernetes with shared supervisors and am validating service discovery and application ingress at 3,000 sandboxes / 6,000 services. I need the control-plane gateways to remain available while that fleet is stable and application traffic flows directly through supervisor listeners.
Problem Statement
OpenShell gateway containers repeatedly grow toward their configured 4 GiB memory limits and terminate with OOMKilled / exit 137. Increasing the gateway replica count from two to three did not eliminate the terminations. The allocation source and whether the working set would plateau at a larger budget are not established.
This issue captures the observation for later triage, separately from the routing fixes in #6183. The test images predate the pending main rebase; reproduction against rebuilt rebased images remains required.
Impact / Why This Matters
The control plane repeatedly loses gateway processes with a stable sandbox fleet. The two-replica run also recorded three failed control-plane inventory calls with EOF/deadline errors. Application requests continued through the separate data plane, but that does not qualify gateway availability or memory stability. Additional replicas alone have not resolved the observed growth.
Observed Evidence
| Configuration | Observation |
|---|---|
| 2 gateways, each limited to 4 GiB | Each container restarted six times during 66.45 full-population minutes: counters 0→6 and 1→7. |
| 3 gateways, same images and memory limits | Each container restarted twice during the interrupted comparison: counters 0→2, 74→76, and 75→77. Full-population duration was 2,542 seconds (42.37 minutes). |
Working-set samples repeatedly climbed from approximately 0.6–1.3 GiB toward 4 GiB and reset after container restart. Pod identities remained unchanged. The original pair continued accumulating restarts after the earlier load stopped; their counters were 74 each at the later preflight, so Locust traffic alone does not explain the observation.
Representative captured container status:
resources.limits.memory: 4Gi
lastState.terminated.reason: OOMKilled
lastState.terminated.exitCode: 137
The three-replica comparison retained 3,000 Ready sandboxes, 3,000 persisted installation records, and all 6,000 routes. Successful observations showed unchanged sandbox identities, ownership and installation versions, with no inventory-monitor errors. It recorded 14,242,874 operations and 596 DNS failures; no non-DNS request failure was recorded. The run was stopped intentionally to finish fixes and rebuild the rebased stack, so it is not a completed qualification.
Reproduction Steps
- Deploy the stack through the Helm chart with PostgreSQL, twelve shared supervisors, application listeners and discovery enabled, and two OpenShell gateway replicas. Give each gateway a 4 GiB memory limit and six-core CPU limit (requests were 1 GiB / four cores).
- Populate a stable fleet of 3,000 sandboxes exposing two services each. Direct application traffic through the Envoy discovery-consumer example to supervisor application listeners, bypassing the OpenShell gateway data path.
- Observe gateway working set, container termination reasons/restart counts, and control-plane availability during a quiet period and a sustained mixed-workload run. Retain the normal 3,600-second JWT lifetime.
- Increase only the OpenShell gateway replica count from two to three through Helm and repeat with the same fleet, images, and resource limits.
Environment
- OpenShell functional changes equivalent to fixes head
420435e2bbdbb0139d2a9af941ce619e4a437654, with four local DEBUG-only instrumentation differences. - Gateway image digest:
sha256:e61d98ef61be4088e9133a8afd46dd2cb70e4a919c4287d62559f2c41da57c74. - GKE, Kubernetes compute driver, shared-supervisor topology, PostgreSQL, Helm deployment.
- Public Envoy Gateway TLS passthrough → Envoy discovery example → supervisor app listener → sandbox service. OpenShell gateways carry management/discovery traffic.
- The comparison used 30,000 allocated clients; load workers are now stopped and the fleet remains deployed.
Triage Leads and Limits
- High-memory periods appeared associated with activity in the active database
reconciler_leaseholder. This is a correlation, not a proven allocation site. The unrelated Kubernetes Lease does not identify this holder. - Persisted object counts remained normal: 3,000 sandbox/installation/assignment/owner/report records and 6,000 service endpoints. Aggregate persisted payloads were tens of MiB.
- Sampled log tails contained zero to 48 lines with small message payloads. Those samples do not establish retained allocation capacity or rule out allocator effects.
- Profile allocations and distinguish live heap, retained allocator memory, and other container memory before treating this as a specific leak or increasing limits as the fix.
- Related prior work: bug(gateway): per-sandbox log/event buffers pre-allocate ~3.4 MiB even when idle #5399, bug(gateway): sandbox log/event buffers are freed on only one replica #5401 and bug(gateway): sandbox log/event buffers are re-created after delete and leak #5402 are closed; bug(gateway): per-sandbox log tail holds up to ~3.7 MiB #5400 and perf(gateway): evaluate jemalloc so freed memory returns to the OS #5404 track log-tail retention and allocator evaluation. This report does not assume the same cause.
Acceptance Criteria
- Reproduce or explicitly rule out the observation with images rebuilt from the rebased stack and record exact source/image versions.
- Identify the dominant allocations and distinguish a bounded capacity requirement from retained or leaking memory.
- Fix the cause or document a measured, bounded resource-sizing requirement with appropriate regressions where a defect is found.
- Repeat the stable 3,000-sandbox comparison for at least a full normal credential-renewal cycle plus a quiet observation period, without gateway OOMs at the documented resource budget.
- Report control-plane availability separately from application data-plane continuity.
Activity
TaylorMutch commentedon Dec 4, 2026
Related logging redesign: #5948. This OOM investigation remains separate: the dominant allocations and any connection to log retention or ingestion are unproven. Reproduce on rebuilt images and distinguish live heap, allocator retention, and other container memory; the redesign does not establish or resolve the cause.
TaylorMutch commentedon Dec 5, 2026
Closing in favor of #5948 (Move Sandbox Logging to the Supervisor / Data Plane). Gateway-side per-sandbox log and event buffering is the memory/scalability issue to address through that refactor, rather than carrying a separate fix under this issue.
The 3,000-sandbox OOM observations and reproduction details above remain the validation case for that work. Repeat the qualification after the logging refactor to confirm gateway memory stability and control-plane availability at the recorded resource budget.