Skip to content

diag_server: complete serve when cancelled - #5233

Open
Sunil Muthuswamy (sunilmut) wants to merge 3 commits into
microsoft:mainfrom
sunilmut:user/sunilmut/diag-server-cancel-repro
Open

Sunil Muthuswamy (sunilmut) wants to merge 3 commits into
microsoft:mainfrom
sunilmut:user/sunilmut/diag-server-cancel-repro

Conversation

@sunilmut

Copy link
Copy Markdown
Member

DiagServer::serve is documented to serve requests until cancel is dropped,
but only the control server observed cancellation. It returned, while
try_join3 kept awaiting the request and data loops, so serve never
completed and its listeners stayed live.

This change races the control server against the joined request and data
loops, returns the control server's result when it completes, and drops the
supporting loops. Errors from those loops still propagate. This matches the
diagnostics worker's immediate-stop policy without draining detached
requests.

Test changes:

  • Idle and connected shutdown complete after cancellation (both hung before
    the fix).
  • A data-listener error is propagated.

@sunilmut
Sunil Muthuswamy (sunilmut) requested a review from a team as a code owner November 23, 2026 00:33
Copilot AI balanced review requested due to automatic review settings November 23, 2026 00:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the diagnostics shutdown coordination change.

No open issues 🎉

What changed in this PR

Fixes OpenHCL diagnostics shutdown so DiagServer::serve completes when cancellation is signalled or its sender is dropped, rather than waiting indefinitely for supporting loops.

Changes:

  • Races the control server against the supporting loops, dropping remaining loops on completion while preserving error propagation.
  • Clarifies that shutdown does not drain detached requests.
  • Adds regression tests for idle and connected shutdown, control-server cancellation, and data-listener errors.
File Description
openhcl/​diag_server/​src/​lib.rs Updates shutdown coordination and documentation; adds regression tests.
openhcl/​diag_server/​Cargo.toml Adds temporary-directory and tracing test dependencies.
Cargo.lock Records the diagnostics server’s new test dependencies.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block the diagnostics server shutdown fix.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 25, 2026 19:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the diagnostics server shutdown changes.

No open issues 🎉

Review effort: Balanced

Race the control server against the joined request and data loops.
Preserve supporting-loop join behavior and propagate errors.
Match the diagnostics worker's immediate-stop policy without draining
detached requests.

Add tests for idle and connected shutdown and data-listener errors.
Cover control RPC parameters/results, capture/profiler socket transfer,
real child standard IO and terminal IO, file/record streaming, handshake
failure recovery, disconnected services and full Unix RPC dispatch.
No inspect API use, new production changes or dependency changes.

Append tests to the existing diagnostics cancellation branch, preserving
its prior shutdown fix and regression tests without rewriting history.

Complete Linux x64 all-features passing-test production-line coverage:
Before: 16.74% (108/645), 4 passing tests.
After:  90.23% (582/645), 21 passing tests, none ignored.

Remaining gaps include inspect/update handlers, VSOCK binding, TDX-only
setup and defensive IO failures. These are not claimed covered.

Check, all-targets clippy, doc, nextest, complete fresh coverage and final
byte-stable repository formatting passed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Echo 131073 bytes, including NUL and non-UTF8 values, through real child
IO in both pipe-backed and raw-socket modes. Send stdin, receive both
outputs and wait concurrently. Assert every byte, the post-EOF stderr
marker and exit status while clients remain open.

Inspired by Linux and FreeBSD pipe readers draining buffered data
before EOF. Existing small text cases do not protect multi-buffer
binary delivery and exit notification together.
Linux x64 passing production coverage stays 90.23% (582/645).
Passing tests: 21 -> 22; none ignored.
Check, clippy, doc, nextest, complete fresh coverage and byte-stable
final repository fmt passed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sunilmut
Sunil Muthuswamy (sunilmut) force-pushed the user/sunilmut/diag-server-cancel-repro branch from 3f57c93 to 7ee27a3 Compare November 26, 2026 22:10
Copilot AI balanced review requested due to automatic review settings November 26, 2026 22:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the diagnostics shutdown change.

No open issues 🎉

Review effort: Balanced

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.

3 participants