Skip to content

Commit c8734c8

Browse files
refactor: lock placements, status updates and test helpers
1 parent 476f739 commit c8734c8

File tree

2 files changed

+265
-82
lines changed

2 files changed

+265
-82
lines changed

agent/agentcontainers/api.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,17 +1296,14 @@ func (api *API) handleDevcontainerDelete(w http.ResponseWriter, r *http.Request)
12961296
proc.stop()
12971297
}
12981298

1299+
dc.Status = codersdk.WorkspaceAgentDevcontainerStatusStopping
1300+
dc.Error = ""
1301+
api.knownDevcontainers[dc.WorkspaceFolder] = dc
1302+
api.broadcastUpdatesLocked()
12991303
api.mu.Unlock()
13001304

13011305
// Stop and remove the container if it exists.
13021306
if containerID != "" {
1303-
api.mu.Lock()
1304-
dc.Status = codersdk.WorkspaceAgentDevcontainerStatusStopping
1305-
dc.Error = ""
1306-
api.knownDevcontainers[dc.WorkspaceFolder] = dc
1307-
api.broadcastUpdatesLocked()
1308-
api.mu.Unlock()
1309-
13101307
if err := api.ccli.Stop(ctx, containerID); err != nil {
13111308
api.logger.Error(ctx, "unable to stop container", slog.Error(err))
13121309

0 commit comments

Comments
 (0)