Repository navigation
Conversation
18110e2 to
e533793
Compare
d384154 to
6abf0ba
Compare
c838427 to
dd4555f
Compare
8e25620 to
172de2e
Compare
172de2e to
e8bf7f0
Compare
52cf46d to
e1576a7
Compare
e1576a7 to
922055a
Compare
922055a to
35c72d3
Compare
| func AppFamilyFromProto(t proto.Connection_Type) (codersdk.AppFamilyName, error) { | ||
| name, ok := proto.Connection_Type_name[int32(t)] | ||
| if !ok || t == proto.Connection_TYPE_UNSPECIFIED { | ||
| return "", xerrors.Errorf("unknown connection type: %d", t) |
There was a problem hiding this comment.
Why is it an error if we get TYPE_UNSPECIFIED when we have an "unknown" app family?
If you return an error here, then up the call stack in agentapi/connectionlog.go we'll fail to record the entire connection log if the app name is absent and the type is unspecified.
There was a problem hiding this comment.
Changed this so we have the following fallbacks:
app_name->type(now calledkind) ->unknownwith kindssh
35c72d3 to
b920b48
Compare
098d7ce to
8d7e0b3
Compare
8d7e0b3 to
f663788
Compare
f663788 to
43a483e
Compare
| // ConnectionLogKindFromAgentProto returns the kind and app name of an agent | ||
| // connection. Without app_name, the family is the app name. | ||
| func ConnectionLogKindFromAgentProto(conn *agentproto.Connection) (database.ConnectionKind, string) { | ||
| kind := database.ConnectionKindSSH |
There was a problem hiding this comment.
It doesn't make sense to default to SSH here. This is going to cause a lot of pain as many types of connections are assumed to be SSH when they are not.
Why are we even still trying to return a "kind"? The RFC says we're getting rid of the type enum.
There was a problem hiding this comment.
This is no longer an issue with the new refactor of source text column
2cbbbae to
16171c4
Compare
connection_logs.type mixed app names with connection types. Rename it to kind, which records what observed the connection, and rename slug_or_port to app_name_or_port: the app an agent reported, a workspace app slug, or a port. The API type is derived from the app registry on read, so a Cursor session reads as type vscode with app_name cursor. type:vscode matches every app in the family, type:unknown matches apps outside the registry, and the new app: filter matches an agent app name or a workspace app slug. The site's type labels are generated from the registry, and the family is labeled Visual Studio Code.
Replace the kind enum with source, a text column with four known values: agent, workspace_app, port_forwarding, and tunnel. Agent rows keep the app in app_name_or_port, which tells SSH from the web terminal, so a new app or agent feature needs no migration. The migration converts old rows too: vscode, jetbrains, ssh, and reconnecting_pty become source agent with that app name. Both columns convert in one ALTER, so the table is rewritten once, about 1.7s per million rows. db2sdk maps a row's source and app to the API type, and sdk2db maps a type filter back, so the two directions sit together and a test pins them. The agent's connection type maps to an app name in sdk2db, and an unspecified type logs as app unknown instead of being dropped. The VS Code family is labeled VS Code Family, apart from the VS Code app.
Table the rows each migration direction converts, and use fixed SQL, which also fixes the gosec G202 lint on the concatenated column list.
Add app_name to Connection in Agent API v2.12, which is unreleased. The agent sends the app it saw, such as cursor, and coderd stores it normalized. An agent without app_name sends only the type, whose family is the app name, and a connection with neither logs as app unknown. The agent still sets type for coderd releases that predate app_name. Apps outside its frozen families map to SSH, so those releases log them instead of dropping them.
Mark Connection.type deprecated. app_name supersedes it, and agents keep sending the family only for coderd that predates app_name. An SSH client can no longer claim to be the web terminal: a client-supplied reconnecting_pty is logged as unknown, since only the reconnecting PTY server is the web terminal. Drop the test case that pinned a quirk of sshConnectionType.
16171c4 to
1a590db
Compare
Stacked on #29674. Second half of phase 3 of the Scalable IDE Session Types RFC.
Problem
ReportConnectiongets the app name from the SSH session, then maps it down to a family to fit theConnection_Typeenum. A Cursor session reaches coderd asVSCODE, even though session counts already recordcursor.Fix
Add
Connection.app_nameto Agent API v2.12, which is unreleased. The agent sends the app it saw, and coderd stores it inapp_name_or_port, normalized. Every agent connection is logged withsource = agent.typeis deprecated in favor ofapp_name:app_name. It stays frozen at its families, and apps outside them reportSSHinstead ofTYPE_UNSPECIFIED, which those releases rejected, so their sessions are logged instead of dropped. The agent still dials Agent API v2.11, so it keeps connecting to those releases.app_name. Its family becomes the app name, soRECONNECTING_PTYlogs asreconnecting_pty. A connection with neither is logged as appunknown.An SSH client can't pose as the web terminal: a client-supplied
reconnecting_ptyis logged asunknown.Rows then read "Cursor (VS Code Family) session". Per-IDE names reach users once clients send them (CLIENT-643).
Refs #27412