feat(agent): implement recreate for devcontainers (#17308)

This change implements an interface for running `@devcontainers/cli up`
and an API endpoint on the agent for triggering recreate for a running
devcontainer.

A couple of limitations:

1. Synchronous HTTP request, meaning the browser might choose to time it
out before it's done => no result/error (and devcontainer cli command
probably gets killed via ctx cancel).
2. Logs are only written to agent logs via slog, not as a "script" in
the UI.

Both 1 and 2 will be improved in future refactors.

Fixes coder/internal#481
Fixes coder/internal#482
This commit is contained in:
Mathias Fredriksson
2025-04-10 16:16:16 +03:00
committed by GitHub
parent 6dd1056025
commit 25fb34cabe
17 changed files with 1338 additions and 22 deletions
+2 -1
View File
@@ -38,7 +38,8 @@ func (a *agent) apiHandler() http.Handler {
}
ch := agentcontainers.New(agentcontainers.WithLister(a.lister))
promHandler := PrometheusMetricsHandler(a.prometheusRegistry, a.logger)
r.Get("/api/v0/containers", ch.ServeHTTP)
r.Get("/api/v0/containers", ch.List)
r.Post("/api/v0/containers/{id}/recreate", ch.Recreate)
r.Get("/api/v0/listening-ports", lp.handler)
r.Get("/api/v0/netcheck", a.HandleNetcheck)
r.Post("/api/v0/list-directory", a.HandleLS)