Skip to content

feat(coderd): support deleting dev containers#21248

Merged
DanielleMaywood merged 3 commits intomainfrom
danielle/devcontainers/delete/coderd
Dec 24, 2025
Merged

feat(coderd): support deleting dev containers#21248
DanielleMaywood merged 3 commits intomainfrom
danielle/devcontainers/delete/coderd

Conversation

@DanielleMaywood
Copy link
Contributor

@DanielleMaywood DanielleMaywood commented Dec 12, 2025

@DanielleMaywood DanielleMaywood force-pushed the danielle/devcontainers/delete/agent branch from 49794cc to 4504755 Compare December 12, 2025 12:12
@DanielleMaywood DanielleMaywood force-pushed the danielle/devcontainers/delete/coderd branch 4 times, most recently from 1f42081 to 23de949 Compare December 12, 2025 13:33
@DanielleMaywood DanielleMaywood force-pushed the danielle/devcontainers/delete/agent branch from 4504755 to 0fcab3f Compare December 12, 2025 14:43
@DanielleMaywood DanielleMaywood force-pushed the danielle/devcontainers/delete/coderd branch from 23de949 to 265aeb8 Compare December 12, 2025 14:43
@DanielleMaywood DanielleMaywood force-pushed the danielle/devcontainers/delete/coderd branch 5 times, most recently from 68d4817 to 945545b Compare December 16, 2025 13:52
Base automatically changed from danielle/devcontainers/delete/agent to main December 22, 2025 11:28
@DanielleMaywood DanielleMaywood force-pushed the danielle/devcontainers/delete/coderd branch 4 times, most recently from 207bae8 to fa53f07 Compare December 23, 2025 13:34
@DanielleMaywood DanielleMaywood force-pushed the danielle/devcontainers/delete/coderd branch from fa53f07 to 930e705 Compare December 23, 2025 15:06
@DanielleMaywood DanielleMaywood marked this pull request as ready for review December 23, 2025 15:17
})
return
}
if apiAgent.Status != codersdk.WorkspaceAgentConnected {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Add a test for this case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 40ea6ac

defer release()

if err = agentConn.DeleteDevcontainer(ctx, devcontainer); err != nil {
if errors.Is(err, context.Canceled) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this check, correct? IIUC this is using the client's context, so this check is for the case the client cancels the request, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly not fully sure, this is a copy+paste of prior endpoints that do the same thing

// Get a list of containers that the agent is able to detect
cts, err := agentConn.ListContainers(ctx)
if err != nil {
if errors.Is(err, context.Canceled) {
httpapi.Write(ctx, rw, http.StatusRequestTimeout, codersdk.Response{
Message: "Failed to fetch containers from agent.",
Detail: "Request timed out.",
})
return
}
// If the agent returns a codersdk.Error, we can return that directly.
if cerr, ok := codersdk.AsError(err); ok {
httpapi.Write(ctx, rw, cerr.StatusCode(), cerr.Response)
return
}
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
Message: "Internal error fetching containers.",
Detail: err.Error(),
})
return
}

@DanielleMaywood DanielleMaywood merged commit 0552913 into main Dec 24, 2025
27 checks passed
@DanielleMaywood DanielleMaywood deleted the danielle/devcontainers/delete/coderd branch December 24, 2025 12:34
@github-actions github-actions bot locked and limited conversation to collaborators Dec 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants