Skip to content

fix(docker): run the proxy under tini to reap orphans - #88

Merged
rolandjitsu merged 1 commit into
rolandjitsu:mainfrom
profiling:fix/docker-tini
Nov 24, 2026
Merged

rolandjitsu merged 1 commit into
rolandjitsu:mainfrom
profiling:fix/docker-tini

Conversation

@profiling

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

  • fix
  • feat
  • refactor
  • perf
  • docs
  • test
  • build / ci
  • chore

Summary
Closes #87. In the image the proxy is PID 1, so orphaned git processes are reparented to it and never reaped: the detached git maintenance run --auto after every fetch, and the descendants of a killed process group (on cancel or client disconnect). Zombies pile up until the PID limit is hit, then every request fails.

Run the proxy under tini instead of fixing this in the proxy. Reaping orphans is the init's job, and the leak only exists when the proxy is PID 1, which only happens in a container. TINI_SUBREAPER=1 keeps it reaping (without a warning) when another init is PID 1, e.g. docker run --init or a shared Kubernetes PID namespace.

Verified on a local amd64 build of this branch, 5 fetches plus 3 clones killed mid-transfer:

Image PID 1 Zombies
0.2.14 (latest) git-cache-proxy 4 (fetches) + 3 (killed clones), run separately
this branch tini 0
this branch, --init docker-init 0
this branch, --read-only, --cap-drop ALL, no-new-privileges tini 0

SIGTERM still drains and exits 0; the image still runs as 10001 and passes /readyz.

Tests

  • Added / updated tests (unit, plus integration where it fits)
  • Not relevant, because: ...

The Package workflow gains "Check orphaned processes are reaped": it orphans a process inside the smoke container and fails if it stays a zombie. It fails on the 0.2.14 image and passes on this one. arm64 is covered by the same workflow's build matrix (not built locally).

Checklist

  • CI is green locally: cargo fmt --all --check, cargo clippy --all-targets --all-features --locked -- -D warnings, cargo test --all-features
  • Commits follow Conventional Commits; AI-assisted commits carry an Assisted-by: trailer (see CONTRIBUTING.md / AGENTS.md)
  • Preserves the read-only, pull-only invariant (no push or proactive replication to upstream)
  • Docs / README updated if behavior or flags changed (no flag or documented behavior changes)

Breaking change?
No for flags, env, and cache layout: arguments still append to the entrypoint. Inside the container, PID 1 is now tini and the proxy runs under it; signals are forwarded. Overriding the entrypoint (--entrypoint, Kubernetes command:) bypasses tini, the same as today.

As PID 1 the proxy never reaps orphaned git processes: the detached
auto maintenance after each fetch and the descendants of a killed
process group. They pile up as zombies until the PID limit is hit.

Closes rolandjitsu#87

Assisted-by: Claude:claude-opus-5-5
@profiling
profiling marked this pull request as ready for review November 24, 2026 02:30
@rolandjitsu
rolandjitsu merged commit b70d7ba into rolandjitsu:main Nov 24, 2026
11 checks passed
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.

Zombie git processes accumulate when the proxy runs as PID 1

2 participants