Skip to content

feat(coderd/provisionerdserver): insert sub agent resource#21699

Merged
DanielleMaywood merged 13 commits into
mainfrom
danielle/devcontainer-resources/provisionerdserver
Jan 30, 2026
Merged

feat(coderd/provisionerdserver): insert sub agent resource#21699
DanielleMaywood merged 13 commits into
mainfrom
danielle/devcontainer-resources/provisionerdserver

Conversation

@DanielleMaywood

@DanielleMaywood DanielleMaywood commented Jan 27, 2026

Copy link
Copy Markdown
Contributor

Update provisionerdserver to handle the changes introduced to provisionerd in #21602

We create a new relationship between workspace_agent_devcontainers and workspace_agents with the newly created subagent_id.

Base automatically changed from danielle/devcontainer-resources/provisioner to main January 29, 2026 00:01
@DanielleMaywood
DanielleMaywood force-pushed the danielle/devcontainer-resources/provisionerdserver branch 2 times, most recently from 8ed9c0d to 36171bd Compare January 29, 2026 10:46
@DanielleMaywood
DanielleMaywood force-pushed the danielle/devcontainer-resources/provisionerdserver branch from 36171bd to dbb9ad8 Compare January 29, 2026 11:05
@DanielleMaywood
DanielleMaywood marked this pull request as ready for review January 29, 2026 11:09
@DanielleMaywood
DanielleMaywood requested review from johnstcn and mafredri and removed request for mafredri January 29, 2026 11:21

@mafredri mafredri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick review to flag a few things. I'll do a more thorough one later.

Comment thread coderd/database/dbgen/dbgen.go Outdated
Comment thread coderd/database/migrations/000413_add_subagent_id_to_dev_containers.up.sql Outdated
Comment thread coderd/database/queries/workspaceagentdevcontainers.sql
dc.Id = uuid.New().String()

if dc.GetSubagentId() != "" {
subAgentID := uuid.New()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this work with the agent id from proto option used elsewhere in the code?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I fully understand the question

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think this is probably fine, just a very confusing pattern since we're overwriting IDs supplied by the provider. Perhaps a comment is warranted on why we do it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a small comment in f8ad555, although not sure how useful it is.

I've tried to fully understand the surrounding context and why it was needed (without it the added test would fail) but I'll be honest it is slightly going over my head 😅 .

Comment thread coderd/provisionerdserver/provisionerdserver_test.go Outdated
Comment thread coderd/provisionerdserver/provisionerdserver.go
Comment thread coderd/provisionerdserver/provisionerdserver.go Outdated
dc.Id = uuid.New().String()

if dc.GetSubagentId() != "" {
subAgentID := uuid.New()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think this is probably fine, just a very confusing pattern since we're overwriting IDs supplied by the provider. Perhaps a comment is warranted on why we do it?

Comment thread coderd/provisionerdserver/provisionerdserver.go Outdated
Comment thread coderd/provisionerdserver/provisionerdserver.go Outdated
Comment thread coderd/provisionerdserver/provisionerdserver.go Outdated

@mafredri mafredri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few final things, but other than that, looks good. I don't need to re-review.

Comment thread coderd/database/querier_test.go Outdated

// Subagents in devcontainers can also have apps that need
// tracking for task linking, just like the parent agent's
// apps above.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't really explain why we replace the subagent ID. But considering it's a common theme throughout the provisioner implementation, I won't push for it here. We should look at improving the reasoning here or refactoring though, because it's almost like an arcane art. 😄

scriptRunOnStart = append(scriptRunOnStart, true)
scriptRunOnStop = append(scriptRunOnStop, false)
scriptsParams.ScriptRunOnStart = append(scriptsParams.ScriptRunOnStart, true)
scriptsParams.ScriptRunOnStop = append(scriptsParams.ScriptRunOnStop, false)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spent some time scratching my head about this because I had forgotten why I added it, and of course didn't read the comments haha. Not required now, but this should really be broken out into it's own function with a very explicit name.

Comment thread coderd/provisionerdserver/provisionerdserver.go Outdated
@DanielleMaywood
DanielleMaywood merged commit 37aecda into main Jan 30, 2026
45 of 47 checks passed
@DanielleMaywood
DanielleMaywood deleted the danielle/devcontainer-resources/provisionerdserver branch January 30, 2026 17:19
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants