Skip to content

Add managed ephemeral debug containers for pods - #2453

Open
Alex-Souslik wants to merge 2 commits into
freelensapp:mainfrom
Alex-Souslik:codex/issue-962-debug-containers
Open

Alex-Souslik wants to merge 2 commits into
freelensapp:mainfrom
Alex-Souslik:codex/issue-962-debug-containers

Conversation

@Alex-Souslik

@Alex-Souslik Alex-Souslik commented Sep 12, 2026

Copy link
Copy Markdown

Fixes #962

Description of changes:

  • Add a pod Debug... action with a target-container and image picker. Debuggers run independently of their terminals, so closing a shell leaves the container available for reconnecting.
  • Add Open debug shell and Stop debugging controls to managed ephemeral containers. A versioned marker and a container-specific stop file support reconnecting after restarting Freelens and stopping safely when process namespaces are shared.
  • Create through the ephemeralcontainers subresource using strategic merge with pod UID/resource-version preconditions and bounded conflict retries. Check permissions and pod identity, preserve concurrent additions, and surface startup and API errors.
  • Invoke kubectl directly with argument arrays. Expose wrapped HTTP error codes for retries and use uppercase PATCH, which Kubernetes requires.

This initial implementation supports Linux pods and images containing sh, sleep, and a writable /tmp, without privileged mode. Creation requires patch permission on pods/ephemeralcontainers and create permission on pods/exec. Reading the node is needed when the pod does not declare its OS. Stopped ephemeral containers remain in the pod, as required by Kubernetes.

Validation:

  • Full TypeScript check, Biome, and git diff --check passed.
  • The targeted Vitest run passed 69 tests, including all debug-container, HTTP, shell-routing, and renderer tests.
  • Four live scenarios on kind v0.33.0 / Kubernetes v1.37.0: concurrent creation and isolated stopping in normal and shared-process-namespace pods; shell exit/reconnection; persisted lifecycle recognition and idempotency; namespace RBAC denial; invalid image startup; stale pod UID rejection. The disposable cluster was removed afterward.
  • DI registrations regenerated. The generator's formatter subprocess could not start, so its generated output was formatted directly with the same pinned Biome version.
  • Trunk was attempted but its launcher failed to start. A packaged Electron end-to-end run was not performed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create ephemeral containers for debugging

1 participant