mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add workspace restart functionality to API (#25757)
This models restart as durable orchestration of existing stop and start workspace builds instead of adding a new restart transition. Keeping restart as two existing transitions preserves the current build/provisioner model. The child start build is created only after the parent stop build succeeds, rather than being inserted immediately in a pending state. That keeps `workspace_builds` aligned with actual provisioner-ready work and avoids introducing a second pending-build lifecycle that the provisioner and build acquisition paths would need to understand. Refs: https://linear.app/codercom/issue/PLAT-143
This commit is contained in:
@@ -259,6 +259,12 @@ export const RBACResourceActions: Partial<
|
||||
read: "read workspace agent resource monitor",
|
||||
update: "update workspace agent resource monitor",
|
||||
},
|
||||
workspace_build_orchestration: {
|
||||
create: "create a workspace build orchestration",
|
||||
delete: "delete a workspace build orchestration",
|
||||
read: "read a workspace build orchestration",
|
||||
update: "update a workspace build orchestration",
|
||||
},
|
||||
workspace_dormant: {
|
||||
application_connect: "connect to workspace apps via browser",
|
||||
create: "create a new workspace",
|
||||
|
||||
Generated
+53
@@ -706,6 +706,11 @@ export type APIKeyScope =
|
||||
| "workspace_agent_resource_monitor:update"
|
||||
| "workspace:*"
|
||||
| "workspace:application_connect"
|
||||
| "workspace_build_orchestration:*"
|
||||
| "workspace_build_orchestration:create"
|
||||
| "workspace_build_orchestration:delete"
|
||||
| "workspace_build_orchestration:read"
|
||||
| "workspace_build_orchestration:update"
|
||||
| "workspace:create"
|
||||
| "workspace:create_agent"
|
||||
| "workspace:delete"
|
||||
@@ -941,6 +946,11 @@ export const APIKeyScopes: APIKeyScope[] = [
|
||||
"workspace_agent_resource_monitor:update",
|
||||
"workspace:*",
|
||||
"workspace:application_connect",
|
||||
"workspace_build_orchestration:*",
|
||||
"workspace_build_orchestration:create",
|
||||
"workspace_build_orchestration:delete",
|
||||
"workspace_build_orchestration:read",
|
||||
"workspace_build_orchestration:update",
|
||||
"workspace:create",
|
||||
"workspace:create_agent",
|
||||
"workspace:delete",
|
||||
@@ -3942,6 +3952,41 @@ export interface CreateUserSkillRequest {
|
||||
readonly content: string;
|
||||
}
|
||||
|
||||
// From codersdk/workspaces.go
|
||||
/**
|
||||
* CreateWorkspaceBuildOnSuccessRequest queues a follow-up build that
|
||||
* runs after the parent build succeeds. It currently supports
|
||||
* restarting a workspace: the parent build must be a "stop" and this
|
||||
* child build a "start". The child build inherits LogLevel and Reason
|
||||
* from the parent CreateWorkspaceBuildRequest.
|
||||
*/
|
||||
export interface CreateWorkspaceBuildOnSuccessRequest {
|
||||
/**
|
||||
* TemplateVersionID pins the child build to a specific template
|
||||
* version. Pinning requires permission to update the template,
|
||||
* since the active version may change before the child build
|
||||
* runs. When empty, the child build uses the template's active
|
||||
* version at the time it runs.
|
||||
*/
|
||||
readonly template_version_id?: string;
|
||||
/**
|
||||
* Transition must be "start". The parent build's transition must
|
||||
* be "stop".
|
||||
*/
|
||||
readonly transition: WorkspaceTransition;
|
||||
/**
|
||||
* RichParameterValues are applied to the child build. Parameters
|
||||
* not listed here fall back to their values from the previous
|
||||
* build, matching normal build behavior.
|
||||
*/
|
||||
readonly rich_parameter_values?: readonly WorkspaceBuildParameter[];
|
||||
/**
|
||||
* TemplateVersionPresetID selects a preset for the child build.
|
||||
* It requires TemplateVersionID to also be set.
|
||||
*/
|
||||
readonly template_version_preset_id?: string;
|
||||
}
|
||||
|
||||
// From codersdk/workspaces.go
|
||||
export type CreateWorkspaceBuildReason =
|
||||
| "cli"
|
||||
@@ -3993,6 +4038,12 @@ export interface CreateWorkspaceBuildRequest {
|
||||
* Reason sets the reason for the workspace build.
|
||||
*/
|
||||
readonly reason?: CreateWorkspaceBuildReason;
|
||||
/**
|
||||
* OnSuccess queues a follow-up workspace build after this build succeeds.
|
||||
* It currently supports restarting a workspace by starting it after a
|
||||
* successful stop build.
|
||||
*/
|
||||
readonly on_success?: CreateWorkspaceBuildOnSuccessRequest;
|
||||
}
|
||||
|
||||
// From codersdk/workspaceproxy.go
|
||||
@@ -7138,6 +7189,7 @@ export type RBACResource =
|
||||
| "workspace"
|
||||
| "workspace_agent_devcontainers"
|
||||
| "workspace_agent_resource_monitor"
|
||||
| "workspace_build_orchestration"
|
||||
| "workspace_dormant"
|
||||
| "workspace_proxy";
|
||||
|
||||
@@ -7190,6 +7242,7 @@ export const RBACResources: RBACResource[] = [
|
||||
"workspace",
|
||||
"workspace_agent_devcontainers",
|
||||
"workspace_agent_resource_monitor",
|
||||
"workspace_build_orchestration",
|
||||
"workspace_dormant",
|
||||
"workspace_proxy",
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user