Skip to content

fix(daemon): attribute shutdown requests - #631

Merged
zackees merged 1 commit into
mainfrom
fix/shutdown-provenance
Jun 18, 2026
Merged

zackees merged 1 commit into
mainfrom
fix/shutdown-provenance

Conversation

@zackees

@zackees zackees commented Jun 18, 2026 •

Copy link
Copy Markdown
Member

Summary

  • logs shutdown caller provenance from peer address plus fbuild client PID/CWD/exe/argv headers
  • makes refused shutdowns visible in logs with the active operation description
  • sends caller provenance headers from Rust CLI and PyO3 shutdown clients
  • treats non-2xx daemon shutdown responses as Rust CLI errors instead of silent success

Closes #627

Tests

  • soldr cargo fmt --all --check
  • soldr cargo test -p fbuild-daemon handlers::health -- --nocapture
  • soldr cargo test -p fbuild-cli daemon_client -- --nocapture
  • soldr cargo check -p fbuild-python
  • soldr cargo clippy -p fbuild-daemon -p fbuild-cli -p fbuild-python --all-targets -- -D warnings

Note: uv run --script lint timed out after 10 minutes without a diagnostic in this worktree, so the final verification used soldr cargo directly for the touched crates.

Summary by CodeRabbit

  • New Features

    • Shutdown requests now include caller metadata (PID, CWD, executable path, argv) for improved tracking.
  • Improvements

    • Daemon now validates shutdown response status and provides detailed error reporting.
    • Enhanced shutdown logging with client connection information.
    • Better error handling when shutdown requests fail.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Three shutdown callers (fbuild-cli DaemonClient, and fbuild-python Daemon/AsyncDaemon) now build a HeaderMap containing the caller's PID, CWD, executable path, and argv and attach it to the shutdown POST request. The daemon's Axum server is switched to into_make_service_with_connect_info::<SocketAddr>(), and the shutdown handler gains ConnectInfo and HeaderMap extractors, a new ShutdownCaller struct for parsing those headers, and enriched logging for both the conflict and success paths.

Changes

Shutdown Caller Identification

Layer / File(s) Summary
Client-side shutdown caller headers (CLI and Python)
crates/fbuild-cli/src/daemon_client.rs, crates/fbuild-python/src/daemon.rs
shutdown_caller_headers() and insert_shutdown_header() helpers are added in both crates to build a HeaderMap from the process PID, CWD, exe path, and argv. DaemonClient::shutdown attaches these headers and adds HTTP response-status validation. Daemon.stop() and AsyncDaemon.stop() attach the same headers to their shutdown POST requests.
Axum ConnectInfo wiring
crates/fbuild-daemon/src/main.rs
axum::serve is switched to into_make_service_with_connect_info::<SocketAddr>() to enable client peer-address extraction in downstream handlers.
Daemon shutdown handler enrichment and tests
crates/fbuild-daemon/src/handlers/health.rs
The shutdown handler signature gains ConnectInfo(peer) and HeaderMap extractors. A new ShutdownCaller struct with from_headers parses x-fbuild-client-{pid,cwd,exe,argv} header values. Conflict-guard and success-path log lines are enriched with caller metadata. Tests are extended to cover header parsing and the non-force conflict response.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 "Who dares stop my build?" the daemon cried,
Now every shutdown must bear its source with pride —
PID and CWD tucked in header rows,
The peer address revealed wherever traffic flows.
No more mysterious "shutdown requested" lore,
The caller's identity logged forevermore! 🏷️

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(daemon): attribute shutdown requests' clearly summarizes the main change: adding attribution/identification to shutdown requests through caller headers and logging.
Linked Issues check ✅ Passed The PR directly addresses objective #1 from issue #627 by logging shutdown requester provenance (peer address, PID, CWD, executable, argv) and improves error handling in the Rust CLI for non-2xx responses.
Out of Scope Changes check ✅ Passed All changes are scoped to shutdown request provenance: daemon handlers extract and log caller info, CLI clients attach identification headers, and error handling for non-2xx responses is added. No unrelated changes detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/shutdown-provenance

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees
zackees merged commit 042b054 into main Jun 18, 2026
84 of 90 checks passed
@zackees
zackees deleted the fix/shutdown-provenance branch June 18, 2026 21:50
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

fbuild daemon dies mid-build with 'error decoding response body' under multi-repo / multi-worktree concurrent use

1 participant