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

Commit99d124e

Browse files
authored
feat(agent): enable devcontainers by default (#18533)
1 parentfcf9371 commit99d124e

File tree

11 files changed

+59
-59
lines changed

11 files changed

+59
-59
lines changed

‎agent/agent.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@ type Options struct {
8989
ServiceBannerRefreshInterval time.Duration
9090
BlockFileTransferbool
9191
Execer agentexec.Execer
92-
93-
ExperimentalDevcontainersEnabledbool
94-
ContainerAPIOptions []agentcontainers.Option// Enable ExperimentalDevcontainersEnabled for these to be effective.
92+
Devcontainersbool
93+
DevcontainerAPIOptions []agentcontainers.Option// Enable Devcontainers for these to be effective.
9594
}
9695

9796
typeClientinterface {
@@ -190,8 +189,8 @@ func New(options Options) Agent {
190189
metrics:newAgentMetrics(prometheusRegistry),
191190
execer:options.Execer,
192191

193-
experimentalDevcontainersEnabled:options.ExperimentalDevcontainersEnabled,
194-
containerAPIOptions:options.ContainerAPIOptions,
192+
devcontainers:options.Devcontainers,
193+
containerAPIOptions:options.DevcontainerAPIOptions,
195194
}
196195
// Initially, we have a closed channel, reflecting the fact that we are not initially connected.
197196
// Each time we connect we replace the channel (while holding the closeMutex) with a new one
@@ -272,9 +271,9 @@ type agent struct {
272271
metrics*agentMetrics
273272
execer agentexec.Execer
274273

275-
experimentalDevcontainersEnabledbool
276-
containerAPIOptions[]agentcontainers.Option
277-
containerAPIatomic.Pointer[agentcontainers.API]// Set by apiHandler.
274+
devcontainersbool
275+
containerAPIOptions []agentcontainers.Option
276+
containerAPI atomic.Pointer[agentcontainers.API]// Set by apiHandler.
278277
}
279278

280279
func (a*agent)TailnetConn()*tailnet.Conn {
@@ -311,7 +310,7 @@ func (a *agent) init() {
311310
returna.reportConnection(id,connectionType,ip)
312311
},
313312

314-
ExperimentalDevContainersEnabled:a.experimentalDevcontainersEnabled,
313+
ExperimentalContainers:a.devcontainers,
315314
})
316315
iferr!=nil {
317316
panic(err)
@@ -340,7 +339,7 @@ func (a *agent) init() {
340339
a.metrics.connectionsTotal,a.metrics.reconnectingPTYErrors,
341340
a.reconnectingPTYTimeout,
342341
func(s*reconnectingpty.Server) {
343-
s.ExperimentalDevcontainersEnabled=a.experimentalDevcontainersEnabled
342+
s.ExperimentalContainers=a.devcontainers
344343
},
345344
)
346345
goa.runLoop()
@@ -1087,9 +1086,9 @@ func (a *agent) handleManifest(manifestOK *checkpoint) func(ctx context.Context,
10871086
slog.F("parent_id",manifest.ParentID),
10881087
slog.F("agent_id",manifest.AgentID),
10891088
)
1090-
ifa.experimentalDevcontainersEnabled {
1089+
ifa.devcontainers {
10911090
a.logger.Info(ctx,"devcontainers are not supported on sub agents, disabling feature")
1092-
a.experimentalDevcontainersEnabled=false
1091+
a.devcontainers=false
10931092
}
10941093
}
10951094
a.client.RewriteDERPMap(manifest.DERPMap)
@@ -1145,7 +1144,7 @@ func (a *agent) handleManifest(manifestOK *checkpoint) func(ctx context.Context,
11451144
scripts=manifest.Scripts
11461145
scriptRunnerOpts []agentscripts.InitOption
11471146
)
1148-
ifa.experimentalDevcontainersEnabled {
1147+
ifa.devcontainers {
11491148
vardcScripts []codersdk.WorkspaceAgentScript
11501149
scripts,dcScripts=agentcontainers.ExtractAndInitializeDevcontainerScripts(manifest.Devcontainers,scripts)
11511150
// See ExtractAndInitializeDevcontainerScripts for motivation

‎agent/agent_test.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,8 +1954,8 @@ func TestAgent_ReconnectingPTYContainer(t *testing.T) {
19541954

19551955
// nolint: dogsled
19561956
conn,_,_,_,_:=setupAgent(t, agentsdk.Manifest{},0,func(_*agenttest.Client,o*agent.Options) {
1957-
o.ExperimentalDevcontainersEnabled=true
1958-
o.ContainerAPIOptions=append(o.ContainerAPIOptions,
1957+
o.Devcontainers=true
1958+
o.DevcontainerAPIOptions=append(o.DevcontainerAPIOptions,
19591959
agentcontainers.WithContainerLabelIncludeFilter("this.label.does.not.exist.ignore.devcontainers","true"),
19601960
)
19611961
})
@@ -2161,9 +2161,9 @@ func TestAgent_DevcontainerAutostart(t *testing.T) {
21612161

21622162
//nolint:dogsled
21632163
_,agentClient,_,_,_:=setupAgent(t,manifest,0,func(_*agenttest.Client,o*agent.Options) {
2164-
o.ExperimentalDevcontainersEnabled=true
2165-
o.ContainerAPIOptions=append(
2166-
o.ContainerAPIOptions,
2164+
o.Devcontainers=true
2165+
o.DevcontainerAPIOptions=append(
2166+
o.DevcontainerAPIOptions,
21672167
// Only match this specific dev container.
21682168
agentcontainers.WithClock(mClock),
21692169
agentcontainers.WithContainerLabelIncludeFilter("devcontainer.local_folder",tempWorkspaceFolder),
@@ -2312,8 +2312,8 @@ func TestAgent_DevcontainerRecreate(t *testing.T) {
23122312

23132313
//nolint:dogsled
23142314
conn,client,_,_,_:=setupAgent(t,manifest,0,func(_*agenttest.Client,o*agent.Options) {
2315-
o.ExperimentalDevcontainersEnabled=true
2316-
o.ContainerAPIOptions=append(o.ContainerAPIOptions,
2315+
o.Devcontainers=true
2316+
o.DevcontainerAPIOptions=append(o.DevcontainerAPIOptions,
23172317
agentcontainers.WithContainerLabelIncludeFilter("devcontainer.local_folder",workspaceFolder),
23182318
)
23192319
})
@@ -2438,8 +2438,7 @@ func TestAgent_DevcontainersDisabledForSubAgent(t *testing.T) {
24382438

24392439
// Setup the agent with devcontainers enabled initially.
24402440
//nolint:dogsled
2441-
conn,_,_,_,_:=setupAgent(t,manifest,0,func(_*agenttest.Client,o*agent.Options) {
2442-
o.ExperimentalDevcontainersEnabled=true
2441+
conn,_,_,_,_:=setupAgent(t,manifest,0,func(*agenttest.Client,*agent.Options) {
24432442
})
24442443

24452444
// Query the containers API endpoint. This should fail because

‎agent/agentssh/agentssh.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,10 @@ type Config struct {
113113
BlockFileTransferbool
114114
// ReportConnection.
115115
ReportConnectionreportConnectionFunc
116-
// Experimental: allow connecting to running containers if
117-
// CODER_AGENT_DEVCONTAINERS_ENABLE=true.
118-
ExperimentalDevContainersEnabledbool
116+
// Experimental: allow connecting to running containers via Docker exec.
117+
// Note that this is different from the devcontainers feature, which uses
118+
// subagents.
119+
ExperimentalContainersbool
119120
}
120121

121122
typeServerstruct {
@@ -435,7 +436,7 @@ func (s *Server) sessionHandler(session ssh.Session) {
435436
switchss:=session.Subsystem();ss {
436437
case"":
437438
case"sftp":
438-
ifs.config.ExperimentalDevContainersEnabled&&container!="" {
439+
ifs.config.ExperimentalContainers&&container!="" {
439440
closeCause("sftp not yet supported with containers")
440441
_=session.Exit(1)
441442
return
@@ -549,7 +550,7 @@ func (s *Server) sessionStart(logger slog.Logger, session ssh.Session, env []str
549550

550551
varei usershell.EnvInfoer
551552
varerrerror
552-
ifs.config.ExperimentalDevContainersEnabled&&container!="" {
553+
ifs.config.ExperimentalContainers&&container!="" {
553554
ei,err=agentcontainers.EnvInfo(ctx,s.Execer,container,containerUser)
554555
iferr!=nil {
555556
s.metrics.sessionErrors.WithLabelValues(magicTypeLabel,ptyLabel,"container_env_info").Add(1)

‎agent/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (a *agent) apiHandler(aAPI proto.DRPCAgentClient26) (http.Handler, func() e
4040
cacheDuration:cacheDuration,
4141
}
4242

43-
ifa.experimentalDevcontainersEnabled {
43+
ifa.devcontainers {
4444
containerAPIOpts:= []agentcontainers.Option{
4545
agentcontainers.WithExecer(a.execer),
4646
agentcontainers.WithCommandEnv(a.sshServer.CommandEnv),

‎agent/reconnectingpty/server.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ type Server struct {
3131
connCount atomic.Int64
3232
reconnectingPTYs sync.Map
3333
timeout time.Duration
34-
35-
ExperimentalDevcontainersEnabledbool
34+
// Experimental: allow connecting to running containers via Docker exec.
35+
// Note that this is different from the devcontainers feature, which uses
36+
// subagents.
37+
ExperimentalContainersbool
3638
}
3739

3840
// NewServer returns a new ReconnectingPTY server
@@ -187,7 +189,7 @@ func (s *Server) handleConn(ctx context.Context, logger slog.Logger, conn net.Co
187189
}()
188190

189191
varei usershell.EnvInfoer
190-
ifs.ExperimentalDevcontainersEnabled&&msg.Container!="" {
192+
ifs.ExperimentalContainers&&msg.Container!="" {
191193
dei,err:=agentcontainers.EnvInfo(ctx,s.commandCreator.Execer,msg.Container,msg.ContainerUser)
192194
iferr!=nil {
193195
returnxerrors.Errorf("get container env info: %w",err)

‎cli/agent.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
5555
blockFileTransferbool
5656
agentHeaderCommandstring
5757
agentHeader []string
58-
59-
experimentalDevcontainersEnabledbool
58+
devcontainersbool
6059
)
6160
cmd:=&serpent.Command{
6261
Use:"agent",
@@ -321,7 +320,7 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
321320
returnxerrors.Errorf("create agent execer: %w",err)
322321
}
323322

324-
ifexperimentalDevcontainersEnabled {
323+
ifdevcontainers {
325324
logger.Info(ctx,"agent devcontainer detection enabled")
326325
}else {
327326
logger.Info(ctx,"agent devcontainer detection not enabled")
@@ -359,11 +358,11 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
359358
SSHMaxTimeout:sshMaxTimeout,
360359
Subsystems:subsystems,
361360

362-
PrometheusRegistry:prometheusRegistry,
363-
BlockFileTransfer:blockFileTransfer,
364-
Execer:execer,
365-
ExperimentalDevcontainersEnabled:experimentalDevcontainersEnabled,
366-
ContainerAPIOptions: []agentcontainers.Option{
361+
PrometheusRegistry:prometheusRegistry,
362+
BlockFileTransfer:blockFileTransfer,
363+
Execer:execer,
364+
Devcontainers:devcontainers,
365+
DevcontainerAPIOptions: []agentcontainers.Option{
367366
agentcontainers.WithSubAgentURL(r.agentURL.String()),
368367
},
369368
})
@@ -506,10 +505,10 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
506505
},
507506
{
508507
Flag:"devcontainers-enable",
509-
Default:"false",
508+
Default:"true",
510509
Env:"CODER_AGENT_DEVCONTAINERS_ENABLE",
511510
Description:"Allow the agent to automatically detect running devcontainers.",
512-
Value:serpent.BoolOf(&experimentalDevcontainersEnabled),
511+
Value:serpent.BoolOf(&devcontainers),
513512
},
514513
}
515514

‎cli/exp_rpty_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ func TestExpRpty(t *testing.T) {
116116
})
117117

118118
_=agenttest.New(t,client.URL,agentToken,func(o*agent.Options) {
119-
o.ExperimentalDevcontainersEnabled=true
120-
o.ContainerAPIOptions=append(o.ContainerAPIOptions,
119+
o.Devcontainers=true
120+
o.DevcontainerAPIOptions=append(o.DevcontainerAPIOptions,
121121
agentcontainers.WithContainerLabelIncludeFilter(wantLabel,"true"),
122122
)
123123
})

‎cli/open_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,8 @@ func TestOpenVSCodeDevContainer(t *testing.T) {
334334
})
335335

336336
_=agenttest.New(t,client.URL,agentToken,func(o*agent.Options) {
337-
o.ExperimentalDevcontainersEnabled=true
338-
o.ContainerAPIOptions=append(o.ContainerAPIOptions,
337+
o.Devcontainers=true
338+
o.DevcontainerAPIOptions=append(o.DevcontainerAPIOptions,
339339
agentcontainers.WithContainerCLI(mccli),
340340
agentcontainers.WithContainerLabelIncludeFilter("this.label.does.not.exist.ignore.devcontainers","true"),
341341
)
@@ -509,8 +509,8 @@ func TestOpenVSCodeDevContainer_NoAgentDirectory(t *testing.T) {
509509
})
510510

511511
_=agenttest.New(t,client.URL,agentToken,func(o*agent.Options) {
512-
o.ExperimentalDevcontainersEnabled=true
513-
o.ContainerAPIOptions=append(o.ContainerAPIOptions,
512+
o.Devcontainers=true
513+
o.DevcontainerAPIOptions=append(o.DevcontainerAPIOptions,
514514
agentcontainers.WithContainerCLI(mccli),
515515
agentcontainers.WithContainerLabelIncludeFilter("this.label.does.not.exist.ignore.devcontainers","true"),
516516
)

‎cli/ssh_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,8 +2029,8 @@ func TestSSH_Container(t *testing.T) {
20292029
})
20302030

20312031
_=agenttest.New(t,client.URL,agentToken,func(o*agent.Options) {
2032-
o.ExperimentalDevcontainersEnabled=true
2033-
o.ContainerAPIOptions=append(o.ContainerAPIOptions,
2032+
o.Devcontainers=true
2033+
o.DevcontainerAPIOptions=append(o.DevcontainerAPIOptions,
20342034
agentcontainers.WithContainerLabelIncludeFilter("this.label.does.not.exist.ignore.devcontainers","true"),
20352035
)
20362036
})
@@ -2069,8 +2069,8 @@ func TestSSH_Container(t *testing.T) {
20692069
Warnings:nil,
20702070
},nil).AnyTimes()
20712071
_=agenttest.New(t,client.URL,agentToken,func(o*agent.Options) {
2072-
o.ExperimentalDevcontainersEnabled=true
2073-
o.ContainerAPIOptions=append(o.ContainerAPIOptions,
2072+
o.Devcontainers=true
2073+
o.DevcontainerAPIOptions=append(o.DevcontainerAPIOptions,
20742074
agentcontainers.WithContainerCLI(mLister),
20752075
agentcontainers.WithContainerLabelIncludeFilter("this.label.does.not.exist.ignore.devcontainers","true"),
20762076
)

‎cli/testdata/coder_agent_--help.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ OPTIONS:
3333
--debug-address string, $CODER_AGENT_DEBUG_ADDRESS (default: 127.0.0.1:2113)
3434
The bind address to serve a debug HTTP server.
3535

36-
--devcontainers-enable bool, $CODER_AGENT_DEVCONTAINERS_ENABLE (default:false)
36+
--devcontainers-enable bool, $CODER_AGENT_DEVCONTAINERS_ENABLE (default:true)
3737
Allow the agent to automatically detect running devcontainers.
3838

3939
--log-dir string, $CODER_AGENT_LOG_DIR (default: /tmp)

‎coderd/workspaceagents_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,8 +1250,8 @@ func TestWorkspaceAgentContainers(t *testing.T) {
12501250
returnagents
12511251
}).Do()
12521252
_=agenttest.New(t,client.URL,r.AgentToken,func(o*agent.Options) {
1253-
o.ExperimentalDevcontainersEnabled=true
1254-
o.ContainerAPIOptions=append(o.ContainerAPIOptions,
1253+
o.Devcontainers=true
1254+
o.DevcontainerAPIOptions=append(o.DevcontainerAPIOptions,
12551255
agentcontainers.WithContainerLabelIncludeFilter("this.label.does.not.exist.ignore.devcontainers","true"),
12561256
)
12571257
})
@@ -1358,8 +1358,8 @@ func TestWorkspaceAgentContainers(t *testing.T) {
13581358
}).Do()
13591359
_=agenttest.New(t,client.URL,r.AgentToken,func(o*agent.Options) {
13601360
o.Logger=logger.Named("agent")
1361-
o.ExperimentalDevcontainersEnabled=true
1362-
o.ContainerAPIOptions=append(o.ContainerAPIOptions,
1361+
o.Devcontainers=true
1362+
o.DevcontainerAPIOptions=append(o.DevcontainerAPIOptions,
13631363
agentcontainers.WithContainerCLI(mcl),
13641364
agentcontainers.WithContainerLabelIncludeFilter("this.label.does.not.exist.ignore.devcontainers","true"),
13651365
)
@@ -1473,9 +1473,9 @@ func TestWorkspaceAgentRecreateDevcontainer(t *testing.T) {
14731473
}).Do()
14741474
_=agenttest.New(t,client.URL,r.AgentToken,func(o*agent.Options) {
14751475
o.Logger=logger.Named("agent")
1476-
o.ExperimentalDevcontainersEnabled=true
1477-
o.ContainerAPIOptions=append(
1478-
o.ContainerAPIOptions,
1476+
o.Devcontainers=true
1477+
o.DevcontainerAPIOptions=append(
1478+
o.DevcontainerAPIOptions,
14791479
agentcontainers.WithContainerCLI(mccli),
14801480
agentcontainers.WithDevcontainerCLI(mdccli),
14811481
agentcontainers.WithWatcher(watcher.NewNoop()),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp