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:
George K
2026-07-07 09:18:30 -07:00
committed by GitHub
parent ba094c5706
commit 6af0f4d698
45 changed files with 4412 additions and 144 deletions
+56
View File
@@ -15721,6 +15721,11 @@ const docTemplate = `{
"workspace_agent_resource_monitor:create",
"workspace_agent_resource_monitor:read",
"workspace_agent_resource_monitor:update",
"workspace_build_orchestration:*",
"workspace_build_orchestration:create",
"workspace_build_orchestration:delete",
"workspace_build_orchestration:read",
"workspace_build_orchestration:update",
"workspace_dormant:*",
"workspace_dormant:application_connect",
"workspace_dormant:create",
@@ -15956,6 +15961,11 @@ const docTemplate = `{
"APIKeyScopeWorkspaceAgentResourceMonitorCreate",
"APIKeyScopeWorkspaceAgentResourceMonitorRead",
"APIKeyScopeWorkspaceAgentResourceMonitorUpdate",
"APIKeyScopeWorkspaceBuildOrchestrationAll",
"APIKeyScopeWorkspaceBuildOrchestrationCreate",
"APIKeyScopeWorkspaceBuildOrchestrationDelete",
"APIKeyScopeWorkspaceBuildOrchestrationRead",
"APIKeyScopeWorkspaceBuildOrchestrationUpdate",
"APIKeyScopeWorkspaceDormantAll",
"APIKeyScopeWorkspaceDormantApplicationConnect",
"APIKeyScopeWorkspaceDormantCreate",
@@ -18759,6 +18769,42 @@ const docTemplate = `{
}
}
},
"codersdk.CreateWorkspaceBuildOnSuccessRequest": {
"type": "object",
"required": [
"transition"
],
"properties": {
"rich_parameter_values": {
"description": "RichParameterValues are applied to the child build. Parameters\nnot listed here fall back to their values from the previous\nbuild, matching normal build behavior.",
"type": "array",
"items": {
"$ref": "#/definitions/codersdk.WorkspaceBuildParameter"
}
},
"template_version_id": {
"description": "TemplateVersionID pins the child build to a specific template\nversion. Pinning requires permission to update the template,\nsince the active version may change before the child build\nruns. When empty, the child build uses the template's active\nversion at the time it runs.",
"type": "string",
"format": "uuid"
},
"template_version_preset_id": {
"description": "TemplateVersionPresetID selects a preset for the child build.\nIt requires TemplateVersionID to also be set.",
"type": "string",
"format": "uuid"
},
"transition": {
"description": "Transition must be \"start\". The parent build's transition must\nbe \"stop\".",
"enum": [
"start"
],
"allOf": [
{
"$ref": "#/definitions/codersdk.WorkspaceTransition"
}
]
}
}
},
"codersdk.CreateWorkspaceBuildReason": {
"type": "string",
"enum": [
@@ -18800,6 +18846,14 @@ const docTemplate = `{
}
]
},
"on_success": {
"description": "OnSuccess queues a follow-up workspace build after this build succeeds.\nIt currently supports restarting a workspace by starting it after a\nsuccessful stop build.",
"allOf": [
{
"$ref": "#/definitions/codersdk.CreateWorkspaceBuildOnSuccessRequest"
}
]
},
"orphan": {
"description": "Orphan may be set for the Destroy transition.",
"type": "boolean"
@@ -22759,6 +22813,7 @@ const docTemplate = `{
"workspace",
"workspace_agent_devcontainers",
"workspace_agent_resource_monitor",
"workspace_build_orchestration",
"workspace_dormant",
"workspace_proxy"
],
@@ -22811,6 +22866,7 @@ const docTemplate = `{
"ResourceWorkspace",
"ResourceWorkspaceAgentDevcontainers",
"ResourceWorkspaceAgentResourceMonitor",
"ResourceWorkspaceBuildOrchestration",
"ResourceWorkspaceDormant",
"ResourceWorkspaceProxy"
]