mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: extend workspace build reasons to track connection types (#18827)
This PR introduces new build reason values to identify what type of connection triggered a workspace build, helping to troubleshoot workspace-related issues. ## Database Migration Added migration 000349_extend_workspace_build_reason.up.sql that extends the build_reason enum with new values: ``` dashboard, cli, ssh_connection, vscode_connection, jetbrains_connection ``` ## Implementation The build reason is specified through the API when creating new workspace builds: - Dashboard: Automatically sets reason to `dashboard` when users start workspaces via the web interface - CLI `start` command: Sets reason to `cli` when workspaces are started via the command line - CLI `ssh` command: Sets reason to ssh_connection when workspaces are started due to SSH connections - VS Code connections: Will be set to `vscode_connection` by the VS Code extension through CLI hidden flag (https://github.com/coder/vscode-coder/pull/550) - JetBrains connections: Will be set to `jetbrains_connection` by the Jetbrains Toolbox (https://github.com/coder/coder-jetbrains-toolbox/pull/150) and Jetbrains Gateway extension (https://github.com/coder/jetbrains-coder/pull/561) ## UI Changes: * Tooltip with reason in Build history <img width="309" height="457" alt="image" src="https://github.com/user-attachments/assets/bde8440b-bf3b-49a1-a244-ed7e8eb9763c" /> * Reason in Audit Logs Row tooltip <img width="906" height="237" alt="image" src="https://github.com/user-attachments/assets/ebbb62c7-cf07-4398-afbf-323c83fb6426" /> <img width="909" height="188" alt="image" src="https://github.com/user-attachments/assets/1ddbab07-44bf-4dee-8867-b4e2cd56ae96" />
This commit is contained in:
+3
-1
@@ -873,7 +873,9 @@ func getWorkspaceAndAgent(ctx context.Context, inv *serpent.Invocation, client *
|
||||
// It's possible for a workspace build to fail due to the template requiring starting
|
||||
// workspaces with the active version.
|
||||
_, _ = fmt.Fprintf(inv.Stderr, "Workspace was stopped, starting workspace to allow connecting to %q...\n", workspace.Name)
|
||||
_, err = startWorkspace(inv, client, workspace, workspaceParameterFlags{}, buildFlags{}, WorkspaceStart)
|
||||
_, err = startWorkspace(inv, client, workspace, workspaceParameterFlags{}, buildFlags{
|
||||
reason: string(codersdk.BuildReasonSSHConnection),
|
||||
}, WorkspaceStart)
|
||||
if cerr, ok := codersdk.AsError(err); ok {
|
||||
switch cerr.StatusCode() {
|
||||
case http.StatusConflict:
|
||||
|
||||
Reference in New Issue
Block a user