mirror of
https://github.com/coder/coder.git
synced 2026-10-16 14:48:56 +08:00
feat(agent): enforce lifecycle script ordering Honor `coder_script_order` dependencies for startup and shutdown scripts using the existing outcome-aware unit manager. Cron, legacy scripts, and scripts without dependencies retain their existing behavior. - Wait for all prerequisites before running. `success` requires a successful prerequisite; `completion` also accepts failure, timeout, or skip. Skip dependents as soon as a required success becomes impossible, preserving the original failure as the lifecycle error. - Reject invalid dependency graphs before any scripts start and write the reason to every selected script's log. - Log unmet dependencies every 30 seconds and explain skips. Populate display names in the manifest so skip messages use readable names, falling back to Terraform addresses. - Exclude dependency waits from script timeouts, record an outcome on every exit, and use fresh state per execution. Cancellation stops waiters without starting dependents or emitting skip messages. Add regression coverage for ordering, skip propagation, timeouts, cancellation, invalid graphs, and unchanged unordered execution. Refs https://linear.app/codercom/issue/PLAT-549/phase-3-enforce-lifecycle-script-ordering
111 lines
4.1 KiB
Go
111 lines
4.1 KiB
Go
package proto
|
|
|
|
import (
|
|
"github.com/coder/coder/v2/apiversion"
|
|
)
|
|
|
|
// Version history:
|
|
//
|
|
// API v1:
|
|
// - retroactively applied name for the HTTP Rest APIs for the Agent and the
|
|
// JSON over websocket coordination and DERP Map APIs for Tailnet
|
|
//
|
|
// API v2.0:
|
|
// - Shipped in Coder v2.8.0
|
|
// - first dRPC over yamux over websocket APIs for tailnet and agent
|
|
//
|
|
// API v2.1:
|
|
// - Shipped in Coder v2.12.0
|
|
// - Added support for multiple banners via the GetAnnouncementBanners RPC on
|
|
// the Agent API.
|
|
// - No changes to the Tailnet API.
|
|
//
|
|
// API v2.2:
|
|
// - Shipped in Coder v2.13.0
|
|
// - Added support for network telemetry via the PostTelemetry RPC on the
|
|
// Tailnet API.
|
|
// - No changes to the Agent API.
|
|
//
|
|
// API v2.3:
|
|
// - Shipped in Coder v2.18.0
|
|
// - Added support for client Resume Tokens on the Tailnet API via the
|
|
// RefreshResumeToken RPC. (This actually shipped in Coder v2.15.0, but we
|
|
// forgot to increment the API version. If you dial for API v2.2, you MAY
|
|
// be connected to a server that supports RefreshResumeToken, but be
|
|
// prepared to process "unsupported" errors.)
|
|
// - Added support for WorkspaceUpdates RPC on the Tailnet API.
|
|
// - Added support for ScriptCompleted RPC on the Agent API. (This actually
|
|
// shipped in Coder v2.16.0, but we forgot to increment the API version. If
|
|
// you dial for API v2.2, you MAY be connected to a server that supports
|
|
// ScriptCompleted, but be prepared to process "unsupported" errors.)
|
|
//
|
|
// API v2.4:
|
|
// - Shipped in Coder v2.20.0
|
|
// - Added support for GetResourcesMonitoringConfiguration and
|
|
// PushResourcesMonitoringUsage RPCs on the Agent API.
|
|
// - Added support for reporting connection events for auditing via the
|
|
// ReportConnection RPC on the Agent API.
|
|
//
|
|
// API v2.5:
|
|
// - Shipped in Coder v2.23.0
|
|
// - Added `ParentId` to the agent manifest.
|
|
//
|
|
// API v2.6:
|
|
// - Shipped in Coder v2.24.0
|
|
// - Added support for CreateSubAgent RPC on the Agent API.
|
|
// - Added support for DeleteSubAgent RPC on the Agent API.
|
|
// - Added support for ListSubAgents RPC on the Agent API.
|
|
// - Add ORGANIZATION SharingLevel
|
|
//
|
|
// API v2.7:
|
|
// - Added support for ReportBoundaryLogs RPC on the Agent API for forwarding
|
|
// boundary audit logs to coderd.
|
|
//
|
|
// API v2.8:
|
|
// - Added support for pre-created sub agents on the Agent API.
|
|
// - Added support for UpdateAppStatus on the Agent API.
|
|
//
|
|
// API v2.9:
|
|
// - Added session_id and confined_process fields to
|
|
// ReportBoundaryLogsRequest on the Agent API.
|
|
// - Added sequence_number field to BoundaryLog on the Agent API.
|
|
//
|
|
// API v2.10:
|
|
// - Added PushContextState RPC on the Agent API for pushing
|
|
// resolved workspace context snapshots (instruction files,
|
|
// skills, MCP configs, MCP server tool lists) from the
|
|
// agent to coderd. Adds ContextResource, PushContextStateRequest,
|
|
// and PushContextStateResponse messages. The coderd handler
|
|
// ships as a stub returning Unimplemented; the agent push
|
|
// loop shuts down cleanly on that response so older coderd
|
|
// deployments remain interoperable. Real persistence,
|
|
// KindMCPServer provider, and chatd hydration land in
|
|
// CODAGT-569.
|
|
//
|
|
// API v2.11:
|
|
// - Added the session_counts map to Stats on the Agent API, deprecating
|
|
// the fixed session_count_* fields.
|
|
//
|
|
// API v2.12:
|
|
// - Added the client_session_id to TelemetryEvent.
|
|
// - Added client_session_id to Connection on the agent API, for logging the
|
|
// client's session ID in the connections table.
|
|
//
|
|
// API v2.13:
|
|
// - Added app_name and connection_method to Connection on the Agent API.
|
|
// Agents no longer send type.
|
|
//
|
|
// API v2.14:
|
|
// - Added resource_address (field 11) and dependencies (field 12) to
|
|
// WorkspaceAgentScript on the Agent API, with the
|
|
// WorkspaceAgentScriptDependency message. They carry each script's
|
|
// Terraform address and its resolved coder_script_order prerequisites
|
|
// in the manifest. Both are empty for unordered scripts.
|
|
// - A v2.14 agent runs start and stop scripts in dependency order.
|
|
const (
|
|
CurrentMajor = 2
|
|
CurrentMinor = 14
|
|
)
|
|
|
|
var CurrentVersion = apiversion.New(CurrentMajor, CurrentMinor)
|