Skip to content

feat(coderd): add support for external agents to API's and provisioner #19286

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: kacpersaw/feat-coder-attach-database
Choose a base branch
from

Conversation

kacpersaw
Copy link
Contributor

@kacpersaw kacpersaw commented Aug 11, 2025

This pull request introduces support for external workspace management, allowing users to register and manage workspaces that are provisioned and managed outside of the Coder.

Depends on: coder/terraform-provider-coder#424

  • GET /api/v2/init-script - Gets the agent initialization script
    • By default, it returns a script for Linux (amd64), but with query parameters (os and arch) you can get the init script for different platforms
  • GET /api/v2/workspaces/{workspace}/external-agent/{agent}/credentials - Gets credentials for an external agent (enterprise)
  • Updated queries to filter workspaces/templates by the has_external_agent field

Copy link
Contributor Author

kacpersaw commented Aug 11, 2025

@kacpersaw kacpersaw changed the title feat: add support for external agents to API's and provisioner feat(coderd): add support for external agents to API's and provisioner Aug 11, 2025
@kacpersaw kacpersaw force-pushed the kacpersaw/feat-coder-attach-api branch from b641ffe to 07a9c42 Compare August 11, 2025 15:40
@kacpersaw kacpersaw marked this pull request as ready for review August 12, 2025 06:43
@kacpersaw kacpersaw requested a review from deansheather August 12, 2025 06:43
Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

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

Proto changes look fine to me 👍

@kacpersaw kacpersaw force-pushed the kacpersaw/feat-coder-attach-database branch from c012284 to 63fefbb Compare August 12, 2025 12:44
@kacpersaw kacpersaw force-pushed the kacpersaw/feat-coder-attach-api branch from 60cccc2 to 0cf5381 Compare August 12, 2025 12:44
t.Run("OK Linux", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, nil)
script, err := client.InitScript(context.Background(), "linux", "amd64")
Copy link
Member

Choose a reason for hiding this comment

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

Probably should make one of these arm64 for variety, and also assert that the string /bin/coder-OS-ARCH[.exe] shows up

@kacpersaw kacpersaw requested a review from aslilac as a code owner August 13, 2025 09:30
@kacpersaw kacpersaw force-pushed the kacpersaw/feat-coder-attach-database branch from 63fefbb to 6033188 Compare August 13, 2025 10:42
@kacpersaw kacpersaw force-pushed the kacpersaw/feat-coder-attach-api branch from 4e94ed6 to 5a0bf15 Compare August 13, 2025 10:42
@deansheather deansheather self-requested a review August 13, 2025 11:20
@@ -223,6 +223,7 @@ func Workspaces(ctx context.Context, db database.Store, query string, page coder
Valid: values.Has("outdated"),
}
filter.HasAITask = parser.NullableBoolean(values, sql.NullBool{}, "has-ai-task")
Copy link
Member

@deansheather deansheather Aug 13, 2025

Choose a reason for hiding this comment

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

Can you also file a ticket to fix has-ai-task?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Message: "Workspace does not have an external agent.",
})
return
}
Copy link
Member

Choose a reason for hiding this comment

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

This is good but I still think the specific agent should be checked as well.

Copy link
Member

Choose a reason for hiding this comment

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

  • tests

coderd/coderd.go Outdated
@@ -180,6 +180,8 @@ type Options struct {
// Entitlements can come from the enterprise caller if enterprise code is
// included.
Entitlements *entitlements.Set
// HasLicense indicates if a license is installed.
Copy link
Member

Choose a reason for hiding this comment

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

This should just be a field on entitlements.Set if possible.

Copy link
Member

@deansheather deansheather left a comment

Choose a reason for hiding this comment

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

Just minor additions to my previous comments

@kacpersaw kacpersaw force-pushed the kacpersaw/feat-coder-attach-database branch from 6033188 to 9e885fe Compare August 13, 2025 12:08
@kacpersaw kacpersaw force-pushed the kacpersaw/feat-coder-attach-api branch from 5a0bf15 to ed93d09 Compare August 13, 2025 12:08

found := false
for _, resource := range resources {
if resource.Type == "coder_external_agent" && resource.Name == agentName {
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it be better to see if the agent's parent resource ID is a coder_external_agent?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants