Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(agent): start devcontainers through agentcontainers package#18471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
DanielleMaywood merged 25 commits intomainfromdm-devcontainer-log-spam
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
25 commits
Select commitHold shift + click to select a range
978c871
fix(agent): start devcontainers through agentcontainers package
DanielleMaywoodJun 20, 2025
fe99bd6
chore: appease formatter
DanielleMaywoodJun 20, 2025
aeae6e2
chore: fix test, appease linter
DanielleMaywoodJun 20, 2025
916f7e8
chore: feedback
DanielleMaywoodJun 24, 2025
53e256b
Merge branch 'main' into dm-devcontainer-log-spam
DanielleMaywoodJun 24, 2025
91bb43a
chore: re-add script timings
DanielleMaywoodJun 24, 2025
81fe11d
fix: change how containerAPI is stored
DanielleMaywoodJun 24, 2025
5c70a8c
Merge branch 'main' into dm-devcontainer-log-spam
DanielleMaywoodJun 24, 2025
8437ca4
chore: appease linter
DanielleMaywoodJun 24, 2025
2c6a2b1
chore: ensure the last log line is printed
DanielleMaywoodJun 24, 2025
a512ad4
chore: fix typo
DanielleMaywoodJun 24, 2025
c50dc6e
chore: OOPS
DanielleMaywoodJun 24, 2025
4d40ef2
chore: 1 -> 2
DanielleMaywoodJun 24, 2025
ce32e2e
chore: add a status to the timings
DanielleMaywoodJun 24, 2025
32ac48a
chore: initialize containerapi even earlier
DanielleMaywoodJun 24, 2025
738b755
chore: only enable when devcontainers are enabled
DanielleMaywoodJun 24, 2025
3714fec
chore: simplify things a little
DanielleMaywoodJun 24, 2025
996d440
chore: recreate -> create with argument
DanielleMaywoodJun 24, 2025
ae5dd1e
chore: ensure we close and init
DanielleMaywoodJun 24, 2025
9d76cf6
chore: appease linter
DanielleMaywoodJun 24, 2025
7285c39
chore: mock ReadConfig any time
DanielleMaywoodJun 24, 2025
3fce51c
chore: feedback
DanielleMaywoodJun 25, 2025
54aa84a
chore: feedback
DanielleMaywoodJun 25, 2025
3d08d0e
chore: only set status if not set, and run create in test
DanielleMaywoodJun 25, 2025
fa479fc
chore: feedback on poor error message
DanielleMaywoodJun 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
fix: change how containerAPI is stored
  • Loading branch information
@DanielleMaywood
DanielleMaywood committedJun 24, 2025
commit81fe11d05c74f6784b4a4343bbb69b89711a3a00
16 changes: 15 additions & 1 deletionagent/agent.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -280,7 +280,7 @@

experimentalDevcontainersEnabled bool
containerAPIOptions []agentcontainers.Option
containerAPI atomic.Pointer[agentcontainers.API] // Set by apiHandler.
containerAPI atomic.Pointer[agentcontainers.API]
}

func (a *agent) TailnetConn() *tailnet.Conn {
Expand DownExpand Up@@ -1130,7 +1130,7 @@
sentResult = true

// The startup script should only execute on the first run!
if oldManifest == nil {

Check failure on line 1133 in agent/agent.go

View workflow job for this annotation

GitHub Actions/ lint

`if oldManifest == nil` has complex nested blocks (complexity: 20) (nestif)
a.setLifecycle(codersdk.WorkspaceAgentLifecycleStarting)

// Perform overrides early so that Git auth can work even if users
Expand All@@ -1153,6 +1153,20 @@
devcontainerScripts map[uuid.UUID]codersdk.WorkspaceAgentScript
)
if a.experimentalDevcontainersEnabled {
containerAPIOpts := []agentcontainers.Option{
agentcontainers.WithExecer(a.execer),
agentcontainers.WithCommandEnv(a.sshServer.CommandEnv),
agentcontainers.WithScriptLogger(func(logSourceID uuid.UUID) agentcontainers.ScriptLogger {
return a.logSender.GetScriptLogger(logSourceID)
}),
agentcontainers.WithManifestInfo(manifest.OwnerName, manifest.WorkspaceName),
agentcontainers.WithDevcontainers(manifest.Devcontainers, scripts),
agentcontainers.WithSubAgentClient(agentcontainers.NewSubAgentClientFromAPI(a.logger, aAPI)),
}
containerAPIOpts = append(containerAPIOpts, a.containerAPIOptions...)

a.containerAPI.Store(agentcontainers.NewAPI(a.logger.Named("containers"), containerAPIOpts...))

scripts, devcontainerScripts = agentcontainers.ExtractDevcontainerScripts(manifest.Devcontainers, scripts)
}
err = a.scriptRunner.Init(scripts, aAPI.ScriptCompleted, scriptRunnerOpts...)
Expand Down
32 changes: 2 additions & 30 deletionsagent/api.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,15 +7,12 @@

"github.com/go-chi/chi/v5"

"github.com/google/uuid"

"github.com/coder/coder/v2/agent/agentcontainers"
"github.com/coder/coder/v2/agent/proto"
"github.com/coder/coder/v2/coderd/httpapi"
"github.com/coder/coder/v2/codersdk"
)

func (a *agent) apiHandler(aAPI proto.DRPCAgentClient26) (http.Handler, func() error) {

Check failure on line 15 in agent/api.go

View workflow job for this annotation

GitHub Actions/ lint

unused-parameter: parameter 'aAPI' seems to be unused, consider removing or renaming it as _ (revive)
r := chi.NewRouter()
r.Get("/", func(rw http.ResponseWriter, r *http.Request) {
httpapi.Write(r.Context(), rw, http.StatusOK, codersdk.Response{
Expand All@@ -41,34 +38,9 @@
}

if a.experimentalDevcontainersEnabled {
containerAPIOpts := []agentcontainers.Option{
agentcontainers.WithExecer(a.execer),
agentcontainers.WithCommandEnv(a.sshServer.CommandEnv),
agentcontainers.WithScriptLogger(func(logSourceID uuid.UUID) agentcontainers.ScriptLogger {
return a.logSender.GetScriptLogger(logSourceID)
}),
agentcontainers.WithSubAgentClient(agentcontainers.NewSubAgentClientFromAPI(a.logger, aAPI)),
}
manifest := a.manifest.Load()
if manifest != nil {
containerAPIOpts = append(containerAPIOpts,
agentcontainers.WithManifestInfo(manifest.OwnerName, manifest.WorkspaceName),
)

if len(manifest.Devcontainers) > 0 {
containerAPIOpts = append(
containerAPIOpts,
agentcontainers.WithDevcontainers(manifest.Devcontainers, manifest.Scripts),
)
}
if cAPI := a.containerAPI.Load(); cAPI != nil {
r.Mount("/api/v0/containers", cAPI.Routes())
}

// Append after to allow the agent options to override the default options.
containerAPIOpts = append(containerAPIOpts, a.containerAPIOptions...)

containerAPI := agentcontainers.NewAPI(a.logger.Named("containers"), containerAPIOpts...)
r.Mount("/api/v0/containers", containerAPI.Routes())
a.containerAPI.Store(containerAPI)
} else {
r.HandleFunc("/api/v0/containers", func(w http.ResponseWriter, r *http.Request) {
httpapi.Write(r.Context(), w, http.StatusForbidden, codersdk.Response{
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp