feat(agent/agentcontainers): recreate devcontainers concurrently (#18042)

This change introduces a refactor of the devcontainers recreation logic
which is now handled asynchronously rather than being request scoped.
The response was consequently changed from "No Content" to "Accepted" to
reflect this.

A new `Status` field was introduced to the devcontainer struct which
replaces `Running` (bool). This reflects that the devcontainer can now
be in various states (starting, running, stopped or errored).

The status field also protects against multiple concurrent recrations,
as long as they are initiated via the API.

Updates #16424
This commit is contained in:
Mathias Fredriksson
2025-05-26 18:30:52 +03:00
committed by GitHub
parent 60fd03dca6
commit 0731304905
10 changed files with 416 additions and 159 deletions

View File

@ -399,6 +399,17 @@ type WorkspaceAgentDevcontainersResponse struct {
Devcontainers []WorkspaceAgentDevcontainer `json:"devcontainers"`
}
// WorkspaceAgentDevcontainerStatus is the status of a devcontainer.
type WorkspaceAgentDevcontainerStatus string
// WorkspaceAgentDevcontainerStatus enums.
const (
WorkspaceAgentDevcontainerStatusRunning WorkspaceAgentDevcontainerStatus = "running"
WorkspaceAgentDevcontainerStatusStopped WorkspaceAgentDevcontainerStatus = "stopped"
WorkspaceAgentDevcontainerStatusStarting WorkspaceAgentDevcontainerStatus = "starting"
WorkspaceAgentDevcontainerStatusError WorkspaceAgentDevcontainerStatus = "error"
)
// WorkspaceAgentDevcontainer defines the location of a devcontainer
// configuration in a workspace that is visible to the workspace agent.
type WorkspaceAgentDevcontainer struct {
@ -408,9 +419,9 @@ type WorkspaceAgentDevcontainer struct {
ConfigPath string `json:"config_path,omitempty"`
// Additional runtime fields.
Running bool `json:"running"`
Dirty bool `json:"dirty"`
Container *WorkspaceAgentContainer `json:"container,omitempty"`
Status WorkspaceAgentDevcontainerStatus `json:"status"`
Dirty bool `json:"dirty"`
Container *WorkspaceAgentContainer `json:"container,omitempty"`
}
// WorkspaceAgentContainer describes a devcontainer of some sort