Repository navigation
feat(guest-agent): log every request to the serial console - #1626
Merged
Merged
Conversation
Signed-off-by: Kevin Wang <wy721@qq.com>
Signed-off-by: Kevin Wang <wy721@qq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The guest agent leaves no trace of who called which API. Rocket's request tracing does not fit: its
requestspan records the raw URI including the query string, and prpc GET calls take their arguments from the query (GET /GetKey?path=...), so turning it on would put internal call parameters on the host-visible console. It also omits the unix peer credentials and latency, and emits several lines per request.Fix
An
AccessLogfairing on all four listeners (dstack.sock,tappd.sock,external,guest-api) writes one line per request: listener, peer, method, path, status, latency. Stdout already goes tojournal+console; the unit'sRUST_LOGnow enablesdstack_guest_agent::access_log=infoand leaves everything else atwarn.What is logged:
Authorization) and bodies are never logged.dstack.sock,tappd.sock) the query string is dropped too, because it may hold prpc call arguments such as key paths.externalandguest-apikeep it: their callers authenticate through the header, and their query parameters (tail,algorithm,json, ...) are not secrets.sanitize_for_log(control characters blanked, capped at 512 bytes), so a caller cannot forge log lines.external, the fairing runs beforeScopeFairing, so a refused request is logged under the URI it asked for, with 401./prpc/Worker.Versionprobe is skipped, so the console doesn't get a line every 15s.Note: this exposes which internal APIs an app calls, and how often, to whoever can read the serial console. Arguments stay hidden.
Sample output
Captured from
dstack-simulator(which runs the samerun_server).externalwas on127.0.0.1:18090andguest-apionvsock:0xffffffff:18000. Anonymous scopes wereversion,info,health, anddashboard. The fmt timestamp/level/target prefix is trimmed.dstack.sock(/,/v0,/v1), query dropped:tappd.sock(legacy), query dropped:external, query kept:The
GET /prpc/Worker.Versionrequest from loopback in the same run was skipped as the watchdog probe.guest-api(host over vsock), query kept:A grep of the access-log lines for the internal arguments (
wallet,signing) and for the bearer token finds nothing. Unit tests cover both modes: the query and token stay out by default, and an opted-in listener logs the query but not the token.