Skip to content

feat(observability): rearchitect logging UX to remove continuous gateway log ingestion #5948

Backlog

Description

@TaylorMutch

User Story

I use OpenShell in single-host and distributed deployments. I need single-host users to keep the convenience of openshell logs, including live tailing, without continuously pushing supervisor logs to the gateway. For larger distributed deployments, I need logs to integrate with the enterprise log collectors already operating on the nodes so logging volume does not become a control-plane scaling cost.

Problem Statement

The current built-in logging UX depends on supervisors continuously pushing logs to the gateway, which buffers them for CLI, TUI, and API/watch consumers. Log production therefore drives gateway traffic and storage even when no user is reading the logs and an external collector already collects them.

We need a logging architecture that preserves convenient single-host access while allowing distributed deployments to collect and ship logs through standard enterprise infrastructure without continuous supervisor-to-gateway log forwarding.

This follows #5418, which proposed a disable switch and was closed in favor of reconsidering how the gateway fetches logs. It should address the underlying retrieval and collection workflow rather than stop at disabling the current stream.

Impact / Why This Matters

Continuous forwarding adds serialization, network traffic, buffering, and gateway processing costs proportional to fleet activity. External collection does not currently remove those costs. Gateway-local buffers also complicate log access across replicas.

Operators should be able to scale the control plane independently of diagnostic log volume. Single-host users should retain built-in troubleshooting without installing a separate observability stack. Distributed operators should be able to use their existing collection, retention, and query infrastructure without paying for a duplicate gateway ingestion path.

Related scaling reports include #5400 (per-sandbox log-tail memory) and #5462 (partial histories and buffer fan-out across gateway replicas). Those fixes are complementary to this architecture proposal.

Proposed Design

Single-host logging workflow

Preserve the existing openshell logs experience for non-distributed deployments and single-host drivers, including recent-log access, live tailing, and applicable source/level/time filters. Users should not need to discover container names, log paths, or configure an external collector for routine troubleshooting.

Make that experience available without continuously pushing logs into the gateway. Log production alone should not create a standing stream of log records into the control plane. Retrieval may perform work when a user requests logs; the proposal leaves the retrieval mechanism and any gateway mediation to design review.

Account for other consumers of the existing log path, including TUI views and API/watch streams. Define their supported behavior and migration explicitly, including which supervisor, gateway, runtime, and platform-event sources each view includes.

Distributed logging workflow

Integrate supervisor and workload log output with common enterprise collection routines, such as Kubernetes DaemonSet/node-level collectors and equivalent host/container-runtime collectors. Operators should be able to collect, attribute, and ship logs to their chosen backend without continuously routing those records through the OpenShell gateway.

Reuse standard platform log interfaces and existing collectors where they satisfy the workflow. Do not require a new OpenShell-specific aggregation service or a collector sidecar per sandbox as the default approach. Preserve trustworthy sandbox/workspace attribution across dedicated and shared supervisors so operators can find a sandbox's records in their backend.

Define what openshell logs, the TUI, and API/watch consumers offer in a distributed deployment using external collection. Any unavailable sources or partial coverage must be explicit, with actionable guidance to the configured collection workflow. Transparent querying of arbitrary external log backends is not a prerequisite for this proposal.

Documentation sub-story

Audit existing observability documentation before adding new material. Document the supported collection sources, required configuration, identity fields, and how to collect and ship supervisor logs, structured OCSF records, and workload/runtime logs. Include a validated Kubernetes node-level/DaemonSet collector example using a common collector and explain equivalent collection for supported single-host drivers.

Describe rotation, teardown, restart, buffering, loss, and retention limits. Local files and container output are collection sources, not automatically durable archives. Keep the single-host quick-start workflow simple and link distributed operators to collection guidance.

Suggested UX

Existing single-host command spelling remains usable, for example:

openshell logs demo
openshell logs demo --tail
openshell logs demo --source sandbox

These commands provide recent/live logs without requiring background supervisor log pushes to the gateway. A distributed operator instead configures their existing node-level collector to collect OpenShell supervisor and workload output and queries the destination by sandbox identity. Exact distributed configuration and CLI guidance should be settled during design.

Acceptance Criteria

  • Single-host deployments retain recent-log access and live tailing through the existing CLI UX without continuous supervisor-to-gateway log pushes or an external collector requirement.
  • A distributed deployment can collect and ship supervisor, OCSF, and workload/runtime logs through a standard node-level collection pipeline while avoiding continuous gateway log ingestion.
  • Dedicated and shared supervisor collection preserves trustworthy sandbox/workspace attribution and identifies the source of each record.
  • CLI, TUI, and API/watch behavior is defined for both deployment models, including filters, available sources, partial coverage, and migration from current behavior.
  • Log collection/retrieval remains separate from sandbox execution and control operations; slow or unavailable consumers do not stall lifecycle operations or policy enforcement.
  • Representative fleet/load validation compares current and proposed gateway-bound log traffic, gateway resource use, and control-plane performance, including idle readers and active tailing. Report measured results without assuming a particular improvement.
  • Existing docs are audited and updated only where needed, with a validated node-level collector collection-and-shipping example, driver-specific guidance, and explicit delivery/retention limits.

Alternatives Considered

  • Only add a disable switch (feat(observability): allow disabling supervisor log pushes to the gateway #5418). Removes forwarding costs for external-collection users but does not preserve built-in single-host log access without pushes or define the broader UX.
  • Optimize gateway buffers and route everything to the owner (bug(gateway): per-sandbox log tail holds up to ~3.7 MiB #5400, bug: sandbox logs and watch streams ignore gateway ownership in multi-replica mode #5462). Addresses immediate memory/correctness problems while retaining continuous log transport through the control plane.
  • Require external collection for every deployment. Fits distributed operations but adds setup to single-host troubleshooting and loses the existing convenience.
  • Require a collector sidecar per sandbox. May remain useful for specialized collection, but node-level collectors already deployed in enterprises should be a supported primary workflow.
  • Filter logs in gateway interceptors or downstream exporters. Filtering after arrival retains transport and ingestion costs. Network middleware and credential providers do not own the log retrieval/collection workflow.

Existing Documentation and Related Work

Checklist

  • I've reviewed existing issues and the repository's published-docs source.
  • This is a design proposal, not an implementation request.

Activity

  1. TaylorMutch commented on Nov 24, 2026

    @TaylorMutch
    ContributorAuthor

    🏗️ build-plan

    Recommended direction

    Keep the gateway as the authorization and discovery boundary. Replace continuous supervisor log ingestion with on-demand retrieval owned by the compute driver for built-in log access. In distributed deployments, collect supervisor and workload output through the existing node-level logging pipeline independently of OpenShell log readers.

    An active openshell logs --tail may still relay requested records through the gateway. The target is no continuous supervisor log transport or retry loop and no gateway-maintained per-sandbox log history/replay buffers, including gateway-originated sandbox logs. Only bounded transport buffers for active readers are permitted. Status and platform-event replay remain an explicit separate concern. This is a starting recommendation; the first milestone validates the retrieval source and stream semantics before fixing the contract.

    Planning baseline: main at 527b91f78. No assignee, plan comment, or matching open PR was present on #5948 when inspected. Implementation of an exploratory Docker slice was subsequently authorized; its findings are recorded below.

    Current code findings

    • crates/openshell-supervisor-process/src/log_push.rs converts tracing events to structured SandboxLogLine records, places them in a 1,024-line queue, and continuously batches/reconnects through PushSandboxLogs. Dedicated setup is in openshell-supervisor/src/main.rs; shared instances create their own sink and push task in sandbox_instance_host.rs.
    • openshell-server/src/grpc/policy.rs::handle_get_sandbox_logs authorizes workspace/sandbox access and reads TracingLogBus. grpc/sandbox.rs implements the watch path. Gateway-originated sandbox logs and platform events must still be accounted for after removing supervisor ingestion.
    • CLI sandbox_logs uses GetSandboxLogs for history and WatchSandbox for tailing. The TUI also uses both, and openshell sandbox create follows logs. SDK watch consumers and testkit log polling are additional compatibility surfaces.
    • Watch replay currently uses one gateway cursor space for logs and platform events. A driver-native offset cannot silently replace that cursor or imply the same replay guarantees.
    • proto/compute_driver.proto has no log-read service. Its optional extension-service pattern provides a precedent for adding capability-negotiated retrieval without requiring every external driver to implement it.
    • Supervisor stderr and local rotating files already exist. Docker uses the runtime log API elsewhere in the driver; the VM driver captures host supervisor stderr in supervisor.err.log. These are starting points, not proof of filter/replay equivalence.
    • docs/observability/accessing-logs.mdx already covers platform log access, separate supervisor/workload sources, and retention limits. Human shorthand drops structured fields present in SandboxLogLine, so parsing existing text alone cannot be assumed to preserve the current API.

    Milestone 1: settle the source and retrieval contract

    Produce a source/behavior matrix for Docker, Podman, VM, and Kubernetes dedicated/shared supervisors, covering history, follow, filtering, identity, restart/stop/delete, and rotation. Keep Windows MXC as an explicit coordination item for its maintained branch.

    Prototype Docker history plus follow with gateway pushes absent. Compare two approaches:

    1. Preferred: driver reads the platform-owned log source on demand. Preserve machine-readable records through a compact structured output format where needed, rather than reconstructing fields from shorthand. Shared supervisor output must carry trusted per-record sandbox/workspace identity.
    2. Alternative: a bounded supervisor-local structured log source with an authenticated read/follow endpoint. Evaluate this only if native runtime/file retrieval cannot preserve the required behavior; it adds endpoint, routing, and storage responsibilities.

    The prototype must establish a bounded history-to-live handoff, cancellation, limits, and field fidelity. Do not add a new permanent gateway cache or a polling loop per sandbox to approximate demand-driven access.

    Decisions required before implementation:

    • Which output is canonical for interactive structured reads, and how does it coexist with OCSF JSON output without duplicate display/collection?
    • What retention is available after stop/restart, especially when supervisor containers are removed? Preserve existing limits explicitly; do not promise an archive.
    • How do log-source cursors coexist with mixed WatchSandbox status/event/log replay? Evaluate a versioned composite cursor versus an additive log-stream API and compatibility adapter. Do not change existing cursor meaning in place.
    • What happens in distributed collection mode when built-in log retrieval is unavailable? Return explicit coverage/guidance, not an empty success that looks like inactivity.

    Milestone 2: smallest complete implementation slice

    Start with Docker dedicated supervisors and the existing CLI commands:

    openshell logs demo
    openshell logs demo --tail
    openshell logs demo --source sandbox

    Add a capability-negotiated internal driver extension for bounded history/follow, using the optional service pattern. Requests use trusted internal sandbox/runtime identity, not arbitrary caller-supplied container IDs or file paths. Keep public workspace authorization at the gateway. Follow proto/README.md for additive public evolution if required by milestone 1.

    Route CLI, TUI, create-time diagnostics, and supported API/watch log access through a common retrieval path. Preserve source, level, time, line-limit, and ordering behavior deliberately. Merge gateway-originated records only with explicitly defined coverage and cursor semantics. Release resources when the last reader leaves; share readers where practical without creating fleet-wide background streams.

    Once the replacement path works, disable the legacy push task and its queue for this supported configuration as part of the same coherent slice. Keep older/external drivers on an explicit compatibility path until they support retrieval. Do not silently remove log access from unsupported drivers or claim that a partial rollout completes #5948.

    Milestone 3: remaining local drivers and distributed collection

    • Extend the validated contract to Podman and VM using driver-owned runtime logs or host files. Bound reads and handle rotation, truncation, and deleted/recreated resources.
    • Validate Kubernetes DaemonSet collection from node container logs with an OpenTelemetry Collector filelog pipeline (or an established equivalent). Collect dedicated/shared supervisor output and workload/runtime output separately; retain structured OCSF records without double-counting shorthand.
    • Ensure supervisor-generated ordinary diagnostic records as well as OCSF records carry trusted identity where needed. Shared-pod labels identify the supervisor host, not each hosted sandbox. Distinguish untrusted workload claims from supervisor attribution.
    • Specify an explicit deployment policy/capability for built-in retrieval versus external collection. Avoid guessing from replica count or driver name: a Kubernetes deployment can have one replica and a Docker daemon can be remote.
    • Enable distributed operation with no continuous supervisor log pushes or log-only retry/buffer allocation. Define the CLI/TUI/watch guidance for externally collected sources. External-backend query integrations are outside this first scope.

    Milestone 4: compatibility, documentation, and removal

    Finish the SDK/watch migration and older-driver/version behavior before removing the legacy push protocol. Preserve status and platform-event observation independently of log availability. Remove gateway-maintained per-sandbox log history for gateway-originated records as well as supervisor records. Provide a separate on-demand source for gateway history before claiming full UX compatibility; do not retain a gateway cache to fill that gap.

    Update the existing accessing-logs and OCSF pages with supported source/collection behavior and a validated collector recipe. Cover permissions, sandbox/workspace queries, shared-supervisor attribution, collector failure, rotation, teardown, and retention. Update gateway configuration documentation with any TOML/Helm changes, plus relevant crate READMEs. Review skills/openshell-cli, skills/debug-openshell-cluster, and contributor Helm/TUI skills using the sync-agent-infra maintenance map.

    Verification and performance gates

    • Structured history/follow: filters, bounded lines/bytes, invalid queries, history-to-live boundary, slow readers, cancellation, reconnect gaps, rotation, and restart generations.
    • Authorization: cross-workspace denial, stale runtime binding, concurrent shared-supervisor sandboxes, no mixed-tenant output, and no arbitrary path/container selection.
    • Compatibility: old/new drivers, gateway/client combinations supported by policy, CLI/TUI/create diagnostics, status/event-only watches, and mixed watches with explicit replay semantics.
    • E2E: Docker first, then Podman/VM; Kubernetes dedicated/shared supervisors with a node collector, short-lived sandboxes, and teardown/collection failures. Use relevant existing conformance/testkit paths rather than testing only a new helper.
    • Load: compare baseline and proposed behavior at fixed sandbox counts and log rates, with zero readers, one reader, and multiple readers. Measure supervisor-to-gateway log bytes/streams, gateway CPU/RSS, local collection cost, time to first log, and create/exec latency. Under zero-reader load the new mode must not open PushSandboxLogs streams; active-reader cost should depend on requested streams rather than total fleet log production.
    • Run affected Rust/protobuf/schema checks and the relevant sandbox E2E lanes during implementation. Planning itself requires no build or runtime tests.

    How to begin

    Start with milestone 1 and a Docker-only experimental slice that proves recent logs and live tailing with pushes absent. Use those results to finalize the source/cursor contract before expanding across drivers. Split implementation milestones into closable child issues before opening their PRs; retain #5948 as the umbrella until its local UX and distributed collection requirements are met.

    Initial prototype findings

    Local branch: feat/5948-on-demand-log-prototype/TaylorMutch.

    • Opt in with [openshell.drivers.docker] experimental_log_retrieval = true. The built-in Docker factory registers an in-process reader; this is not yet a stable external-driver protocol.
    • New dedicated supervisors write framed structured records to runtime-owned stdout without starting their log-push queue/task. History and follow requests read the immutable supervisor container through Docker's API after gateway authorization and driver identity checks.
    • Registration disables the gateway sandbox log bus, including gateway-originated histories. Active readers have bounded transport buffers; platform-event buffering is unchanged.
    • CLI/TUI coverage warnings identify supervisor-only results. Gateway-only log requests and log resume are unsupported. Provisioning watches continue status/events when their requested gateway log source is unavailable.
    • Docker history/live-tailing smoke passed using Docker Desktop bridge networking. Focused tests cover authorization before reads, record identity/framing, mixed status/log watches, cancellation, and no log-buffer allocation. Existing log bus/push regression tests also passed. This is functional validation, not a fleet performance measurement.

    Next design work: restore gateway-source history through an on-demand source; settle cursor/history-to-live semantics and native runtime tail limits; define a stable driver extension; expand to other drivers and enterprise node collectors. The prototype does not complete #5948.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions