Repository navigation
feat: log and record DERP/direct connection path per agent connection - #30665
Closed
code-asher wants to merge 2 commits into
Closed
code-asher wants to merge 2 commits into
code-asher wants to merge 2 commits into
Conversation
tailnet: connections accepted from a Conn listener are now PeerConns that record the coordinator peer they came from, resolved once at accept time. PeerConn exposes the current path (DERP or direct) and a WatchPath subscription backed by a single shared poller per Conn. watchConnChange also logs path changes on the client, tagged with the client session ID. agent: SSH connections and reconnecting PTYs log their initial path and every change, using loggers that already carry the remote address and client session ID. Connection reports carry the path at connect and at disconnect (agent API v2.13). coderd: store the paths in new connection_logs.connect_path and disconnect_path columns, keeping the first reported value for each.
# Conflicts: # coderd/agentapi/connectionlog_test.go # coderd/database/dump.sql # coderd/database/modelmethods.go # coderd/database/models.go # coderd/database/queries.sql.go # coderd/database/queries/connectionlogs.sql
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Log and record whether each agent connection uses DERP or a direct path, so connection problems can be correlated per connection and per client session.
Connlistener are now*tailnet.PeerConn. The sending peer is resolved once, when the connection is accepted, from the source address. WireGuard only accepts a source address from the peer it belongs to, so the result is authoritative and doesn't depend on later IP lookups.PeerConnexposesPeerID(),Path()andWatchPath(). Watchers share one 1s poller perConn, which runs only while something is subscribed.PeerConnFromConnunwraps wrappers that implementNetConn(), which the agent's HTTP-upgraded conns now do.watchConnChangenow logs DERP/direct changes withclient_session_id.initial connection pathandconnection path changed, includingpeer_id,endpointandderp_region. They use the existing per-connection loggers, which already carryremote_addrandclient_session_id. Connection reports now carryconnect_pathon both connect and disconnect, anddisconnect_pathon disconnect. Agent API version is bumped to v2.13.connection_pathenum and theconnection_logs.connect_path/disconnect_pathcolumns. The upsert and the batcher dedup both keep the first non-NULL value. As withclient_session_id, the columns are not exposed in the API or UI yet.Older agents and web connections leave both columns NULL.
Decision log
watchConnChange. It only starts when aTelemetrySinkis set, which only happens inworkspacesdk.DialAgent, so it runs on the client and never in the agent. It also assumes a single peer, while the agent has one peer per client. It gets a log line for the CLI side, and the agent uses the per-connectionPeerConnAPI.TailscaleServicePrefix.RandomAddr()), so they are not stable identifiers across sessions. Binding the peer once at accept avoids any later IP-based lookup. The physical endpoint (CurAddr) can change while the connection stays up. It is logged asendpoint, and direct-to-direct endpoint changes are logged too.connect_path, so the value survives batch dedup or a lost connect report.Generated by Coder Agents on behalf of @code-asher.