Skip to content

Commit 91ff08e

Browse files
committed
feat(agent/agentcontainers): implement sub agent injection
This change adds support for sub agent creation and injection into dev containers. Closes coder/internal#621
1 parent d49f84e commit 91ff08e

File tree

5 files changed

+698
-35
lines changed

5 files changed

+698
-35
lines changed

agent/agent.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ func (a *agent) handleManifest(manifestOK *checkpoint) func(ctx context.Context,
11881188
// createOrUpdateNetwork waits for the manifest to be set using manifestOK, then creates or updates
11891189
// the tailnet using the information in the manifest
11901190
func (a *agent) createOrUpdateNetwork(manifestOK, networkOK *checkpoint) func(context.Context, proto.DRPCAgentClient26) error {
1191-
return func(ctx context.Context, _ proto.DRPCAgentClient26) (retErr error) {
1191+
return func(ctx context.Context, aAPI proto.DRPCAgentClient26) (retErr error) {
11921192
if err := manifestOK.wait(ctx); err != nil {
11931193
return xerrors.Errorf("no manifest: %w", err)
11941194
}
@@ -1208,6 +1208,7 @@ func (a *agent) createOrUpdateNetwork(manifestOK, networkOK *checkpoint) func(co
12081208
// agent API.
12091209
network, err = a.createTailnet(
12101210
a.gracefulCtx,
1211+
aAPI,
12111212
manifest.AgentID,
12121213
manifest.DERPMap,
12131214
manifest.DERPForceWebSockets,
@@ -1355,6 +1356,7 @@ func (a *agent) trackGoroutine(fn func()) error {
13551356

13561357
func (a *agent) createTailnet(
13571358
ctx context.Context,
1359+
aAPI proto.DRPCAgentClient26,
13581360
agentID uuid.UUID,
13591361
derpMap *tailcfg.DERPMap,
13601362
derpForceWebSockets, disableDirectConnections bool,
@@ -1487,7 +1489,7 @@ func (a *agent) createTailnet(
14871489
}()
14881490
if err = a.trackGoroutine(func() {
14891491
defer apiListener.Close()
1490-
apiHandler, closeAPIHAndler := a.apiHandler()
1492+
apiHandler, closeAPIHAndler := a.apiHandler(aAPI)
14911493
defer func() {
14921494
_ = closeAPIHAndler()
14931495
}()

0 commit comments

Comments
 (0)