8000 feat(agent/agentcontainers): support apps for dev container agents by DanielleMaywood · Pull Request #18346 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat(agent/agentcontainers): support apps for dev container agents #18346

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

Merged
merged 16 commits into from
Jun 18, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: pass env variables + remove accidental commit
  • Loading branch information
DanielleMaywood committed Jun 18, 2025
commit 91fd4e71b21c93b6d6d771822cfd4557ab0f7d97
14 changes: 8 additions & 6 deletions agent/agentcontainers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1146,12 +1146,14 @@ func (api *API) maybeInjectSubAgentIntoContainerLocked(ctx context.Context, dc c

var apps []SubAgentApp

if config, err := api.dccli.ReadConfig(ctx, dc.WorkspaceFolder, dc.ConfigPath, []string{
fmt.Sprintf("CODER_AGENT_NAME=%s", dc.Name),
fmt.Sprintf("CODER_USER_NAME=%s", api.userName),
fmt.Sprintf("CODER_WORKSPACE_NAME=%s", api.workspaceName),
fmt.Sprintf("CODER_DEPLOYMENT_URL=%s", api.subAgentURL),
}); err != nil {
if config, err := api.dccli.ReadConfig(ctx, dc.WorkspaceFolder, dc.ConfigPath,
[]string{
fmt.Sprintf("CODER_WORKSPACE_AGENT_NAME=%s", dc.Name),
fmt.Sprintf("CODER_WORKSPACE_OWNER_NAME=%s", api.userName),
fmt.Sprintf("CODER_WORKSPACE_NAME=%s", api.workspaceName),
fmt.Sprintf("CODER_DEPLOYMENT_URL=%s", api.subAgentURL),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fmt.Sprintf("CODER_DEPLOYMENT_URL=%s", api.subAgentURL),
fmt.Sprintf("CODER_AGENT_URL=%s", api.subAgentURL),

The naming is slightly unfortunate but we currently have both CODER_URL and CODER_AGENT_URL in the product, and a third one seems like too much.

IMO CODER_URL would be more appropriate, however, it would be nice if these environment variables were also set on the parent workspace/agent (with CODER_AGENT_URL we're at 3/4). The reason is that if a user runs devcontainer up manually, these values are then serializable into the docker container label.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've replaced it with CODER_URL. If you'd rather CODER_AGENT_URL I'm happy to update it again.

I don't think we can rely on anything serialized at the point of devcontainer up, as the CODER_WORKSPACE_AGENT_NAME will be the parents agent name, not the child. So I'm not sure there is too much benefit there.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that's a good point about the conflicting env. Let's go with CODER_URL for now 👍🏻

},
); err != nil {
api.logger.Error(ctx, "unable to read devcontainer config", slog.Error(err))
} else {
coderCustomization := config.MergedConfiguration.Customizations.Coder
Expand Down
3 changes: 2 additions & 1 deletion agent/agentcontainers/devcontainercli.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/json"
"errors"
"io"
"os"

"golang.org/x/xerrors"

Expand Down Expand Up @@ -264,7 +265,7 @@ func (d *devcontainerCLI) ReadConfig(ctx context.Context, workspaceFolder, confi
}

c := d.execer.CommandContext(ctx, "devcontainer", args...)
// c.Env = append(c.Env, env...)
c.Env = append(os.Environ(), env...)

var stdoutBuf bytes.Buffer
stdoutWriters := []io.Writer{&stdoutBuf, &devcontainerCLILogWriter{ctx: ctx, logger: logger.With(slog.F("stdout", true))}}
Expand Down
2 changes: 0 additions & 2 deletions site/src/pages/WorkspacePage/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ export const Workspace: FC<WorkspaceProps> = ({
const shouldShowProvisionerAlert =
workspacePending && !haveBuildLogs && !provisionersHealthy && !isRestarting;

console.log(selectedResource?.agents);

return (
<div
css={{
Expand Down
0