Skip to content

feat(git): bound upstream lifetime and cancel work before shutdown drain - #77

Merged
rolandjitsu merged 1 commit into
rolandjitsu:mainfrom
profiling:upstream-lifecycle
Nov 16, 2026
Merged

rolandjitsu merged 1 commit into
rolandjitsu:mainfrom
profiling:upstream-lifecycle

Conversation

@profiling

@profiling profiling commented Nov 14, 2026 •

Copy link
Copy Markdown

A stalled upstream clone or fetch can currently hold the repository lock indefinitely and keep HTTP graceful shutdown waiting. Give each clone, full-ref fetch and SHA backfill a positive total budget (3600 seconds by default), shared across attempts and retry backoff.

Cancel upstream owners on SIGTERM or Ctrl-C before HTTP drain, reject new admission, and interrupt repository lock waits, commands and retry backoff. Independent owners keep repository locks until process-group termination and direct-child reaping complete, including when an HTTP request is dropped. Preserve per-request credentials and typed upstream auth failures; ordinary SHA backfill failures remain best effort. Active local upload-pack responses continue to drain.

Expose the same validated timeout through CLI/env, a library builder and Helm values. No new direct dependency; enable the existing tokio-util runtime feature for cancellation and task tracking.

Validation:

  • cargo fmt --all --check
  • cargo clippy --all-targets --all-features --locked -- -D warnings
  • cargo test --all-features: 173 tests passed
  • Helm 3.17.3 lint/default render and seven valid/invalid timeout value cases
  • Remote CI and Codecov project/patch checks passed; line coverage 97.29%
  • Remote amd64/arm64 image builds and non-root/writable-cache checks passed (no push)
  • Independent Orca review: fixed a descendant-exit assertion race; no other confirmed implementation defects

Tests cover stalled/noisy commands, a shared retry budget, successful operations within budget, auth propagation, request-drop cleanup, cancellation during backoff and lock waits, active upload/permit preservation, and real binary SIGTERM/Ctrl-C shutdown.

The budget starts after the repository lock is acquired. This does not claim a hard shutdown bound for active uploads or blocking filesystem work. Unix cancellation kills the process group and reaps the direct child; orphaned descendants are reaped by their OS parent. On non-Unix targets only the direct child is terminated. No persistence/admission redesign, protocol changes, production changes, or fixed mutation-lock wait policy are included.

Related PRs

Independent of #72 and #76; no required merge order. If either lands first, update this branch against main and adapt any affected tests before merging.

@codecov

codecov Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.77%. Comparing base (b9f2841) to head (530e73d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #77      +/-   ##
==========================================
+ Coverage   97.57%   97.77%   +0.19%     
==========================================
  Files           9        9              
  Lines        3707     4083     +376     
==========================================
+ Hits         3617     3992     +375     
- Misses         90       91       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

profiling pushed a commit to profiling/git-cache-proxy that referenced this pull request Nov 14, 2026
Keep rolandjitsu#72, rolandjitsu#76 and rolandjitsu#77 with internal maintenance while deferring rolandjitsu#67.
Preserve the previous tree on its archive branch and in normal history.

Assisted-by: OpenAI:Codex
@profiling
profiling marked this pull request as ready for review November 14, 2026 07:36

@rolandjitsu rolandjitsu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It mostly LGTM, just a minor comment.

Comment thread tests/lifecycle.rs Resolved
@profiling
profiling marked this pull request as draft November 15, 2026 13:38
@profiling
profiling marked this pull request as ready for review November 15, 2026 14:23
Keep upstream owners alive until their children are killed and reaped,
even when the HTTP request is dropped.

Assisted-by: OpenAI:Codex
Assisted-by: Claude:claude-opus-4-8

@rolandjitsu rolandjitsu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@rolandjitsu
rolandjitsu enabled auto-merge (rebase) November 16, 2026 06:12
@rolandjitsu
rolandjitsu merged commit e74fbc3 into rolandjitsu:main Nov 16, 2026
13 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.

2 participants