refactor(agent): reuse NOW execution for PSU gRPC#1844
refactor(agent): reuse NOW execution for PSU gRPC#1844Marc-André Moreau (mamoreau-devolutions) wants to merge 1 commit into
Conversation
|
Implementation notes:
|
Route the PSU gRPC remote execution path through the existing NOW/DVC Windows process backend while preserving the current gRPC wire protocol. Keep non-Windows execution on the existing tokio fallback and tighten process/stream cleanup and validation around the gRPC adapter. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
ac99194 to
a2e310d
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors the Devolutions Agent's PSU gRPC remote-execution feature so that, on Windows, process launch, stdin/stdout handling, cancellation, and cleanup are delegated to the Agent's existing NOW_EXEC (WinApiProcessBuilder) backend instead of a separate tokio::process path. The gRPC protocol is unchanged. The non-Windows fallback keeps using tokio::process::Command, and duplicate process/stream validation plus failure cleanup around the gRPC adapter are hardened. This aligns the two agent execution surfaces (DVC NOW sessions and PSU gRPC) on a single Windows implementation.
Changes:
- Added a Windows-only
run_process_inner_windowsthat drives the NOW backend (IO redirection, raw encoding, kill-on-drop) and maps NOWServerChannelEvents to PSU protocol messages. - Extended
WinApiProcessBuilder/WinApiProcesswith opt-inwith_kill_on_drop/disable_kill_on_drop, and addedprocess_idtoServerChannelEvent::SessionStarted. - Hardened PSU gRPC handling: reject empty/duplicate correlation & stream IDs, stricter working-directory validation, raw stdout chunking, and pass-through stdin (no injected newlines).
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| devolutions-agent/src/psu_grpc_agent/process.rs | Adds the Windows NOW-backed execution path, duplicate-registry rejection, and raw stdout/stdin handling; adds tests. |
| devolutions-agent/src/psu_grpc_agent/mod.rs | Validates StartProcess IDs and handles duplicate process/stream registration with failure responses. |
| devolutions-session/src/dvc/process.rs | Adds process_id to SessionStarted and opt-in kill-on-drop for WinApiProcess. |
| devolutions-session/src/dvc/task.rs | Updates the SessionStarted consumer to ignore the new field. |
| devolutions-agent/Cargo.toml, Cargo.lock, src/main.rs | Wire in devolutions-session (dvc) and now-proto-pdu as Windows-only dependencies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| AgentPayload::StreamClosed(stream_closed( | ||
| request.stream_id.clone(), | ||
| "child process completed".to_owned(), | ||
| false, | ||
| )), |
Reuses the existing Devolutions Session NOW_EXEC process backend for PSU gRPC remote execution on Windows while keeping the gRPC protocol unchanged. This aligns process launch, stdin/stdout handling, cancellation, and cleanup with the Agent's existing NOW behavior instead of maintaining a separate Windows execution path.
Keeps the non-Windows fallback on tokio process execution and hardens duplicate process/stream validation and failure cleanup around the gRPC adapter.
Issue: N/A