Skip to content

Commit 470f061

Browse files
committed
Merge branch 'main' into dk/prebuilds-docs
2 parents 88f918a + 50695b7 commit 470f061

File tree

326 files changed

+5497
-3930
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

326 files changed

+5497
-3930
lines changed

CODEOWNERS

+2
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ agent/proto/ @spikecurtis @johnstcn
44
tailnet/proto/ @spikecurtis @johnstcn
55
vpn/vpn.proto @spikecurtis @johnstcn
66
vpn/version.go @spikecurtis @johnstcn
7+
provisionerd/proto/ @spikecurtis @johnstcn
8+
provisionersdk/proto/ @spikecurtis @johnstcn

agent/agent.go

+17-7
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ type Options struct {
8989
ServiceBannerRefreshInterval time.Duration
9090
BlockFileTransfer bool
9191
Execer agentexec.Execer
92-
ContainerLister agentcontainers.Lister
9392

9493
ExperimentalDevcontainersEnabled bool
94+
ContainerAPIOptions []agentcontainers.Option // Enable ExperimentalDevcontainersEnabled for these to be effective.
9595
}
9696

9797
type Client interface {
@@ -154,9 +154,6 @@ func New(options Options) Agent {
154154
if options.Execer == nil {
155155
options.Execer = agentexec.DefaultExecer
156156
}
157-
if options.ContainerLister == nil {
158-
options.ContainerLister = agentcontainers.NoopLister{}
159-
}
160157

161158
hardCtx, hardCancel := context.WithCancel(context.Background())
162159
gracefulCtx, gracefulCancel := context.WithCancel(hardCtx)
@@ -192,9 +189,9 @@ func New(options Options) Agent {
192189
prometheusRegistry: prometheusRegistry,
193190
metrics: newAgentMetrics(prometheusRegistry),
194191
execer: options.Execer,
195-
lister: options.ContainerLister,
196192

197193
experimentalDevcontainersEnabled: options.ExperimentalDevcontainersEnabled,
194+
containerAPIOptions: options.ContainerAPIOptions,
198195
}
199196
// Initially, we have a closed channel, reflecting the fact that we are not initially connected.
200197
// Each time we connect we replace the channel (while holding the closeMutex) with a new one
@@ -274,9 +271,10 @@ type agent struct {
274271
// labeled in Coder with the agent + workspace.
275272
metrics *agentMetrics
276273
execer agentexec.Execer
277-
lister agentcontainers.Lister
278274

279275
experimentalDevcontainersEnabled bool
276+
containerAPIOptions []agentcontainers.Option
277+
containerAPI atomic.Pointer[agentcontainers.API] // Set by apiHandler.
280278
}
281279

282280
func (a *agent) TailnetConn() *tailnet.Conn {
@@ -1170,6 +1168,12 @@ func (a *agent) handleManifest(manifestOK *checkpoint) func(ctx context.Context,
11701168
}
11711169
a.metrics.startupScriptSeconds.WithLabelValues(label).Set(dur)
11721170
a.scriptRunner.StartCron()
1171+
if containerAPI := a.containerAPI.Load(); containerAPI != nil {
1172+
// Inform the container API that the agent is ready.
1173+
// This allows us to start watching for changes to
1174+
// the devcontainer configuration files.
1175+
containerAPI.SignalReady()
1176+
}
11731177
})
11741178
if err != nil {
11751179
return xerrors.Errorf("track conn goroutine: %w", err)
@@ -1481,8 +1485,13 @@ func (a *agent) createTailnet(
14811485
}()
14821486
if err = a.trackGoroutine(func() {
14831487
defer apiListener.Close()
1488+
apiHandler, closeAPIHAndler := a.apiHandler()
1489+
defer func() {
1490+
_ = closeAPIHAndler()
1491+
}()
14841492
server := &http.Server{
1485-
Handler: a.apiHandler(),
1493+
BaseContext: func(net.Listener) context.Context { return ctx },
1494+
Handler: apiHandler,
14861495
ReadTimeout: 20 * time.Second,
14871496
ReadHeaderTimeout: 20 * time.Second,
14881497
WriteTimeout: 20 * time.Second,
@@ -1493,6 +1502,7 @@ func (a *agent) createTailnet(
14931502
case <-ctx.Done():
14941503
case <-a.hardCtx.Done():
14951504
}
1505+
_ = closeAPIHAndler()
14961506
_ = server.Close()
14971507
}()
14981508

0 commit comments

Comments
 (0)