Skip to content

feat(agent/agentcontainers): refactor Lister to ContainerCLI and implement new methods #18243

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 2 commits into from
Jun 6, 2025

Conversation

mafredri
Copy link
Member

@mafredri mafredri commented Jun 5, 2025

@mafredri mafredri force-pushed the mafredri/feat-agent-devcontainer-injection-2 branch 2 times, most recently from 2984d4e to ae52380 Compare June 5, 2025 12:56
Base automatically changed from mafredri/feat-agent-devcontainer-injection-1 to main June 5, 2025 13:58
@mafredri mafredri force-pushed the mafredri/feat-agent-devcontainer-injection-2 branch 2 times, most recently from 5cf4ae7 to 2dc395d Compare June 6, 2025 08:44
…ement new methods

This change redefines the Lister interface and implements new methods
needed for sub agent injection.

Updates coder/internal#621
@mafredri mafredri force-pushed the mafredri/feat-agent-devcontainer-injection-2 branch from 2dc395d to ea0125d Compare June 6, 2025 09:25
@mafredri mafredri marked this pull request as ready for review June 6, 2025 09:30
Copy link
Contributor

@DanielleMaywood DanielleMaywood left a comment

Choose a reason for hiding this comment

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

Looks good to me although have left a comment about the ExecAs tests

Comment on lines +560 to +562
// UID 0 is more portable than the name root, so we use that
// because some containers may not have a user named "root".
altUID = "0"
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 wild, do you have an example?

Copy link
Member Author

@mafredri mafredri Jun 6, 2025

Choose a reason for hiding this comment

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

The username is passwd dependent, so there are various ways this could happen. Simple demo:

FROM busybox
RUN rm /etc/passwd
docker run -it --rm --user root test whoami
docker: Error response from daemon: unable to find user root: no matching entries in passwd file

Run 'docker run --help' for more information

Compared to

docker run -it --rm --user 0 test whoami
whoami: unknown uid 0

Comment on lines +546 to +552
func (dcli *dockerCLI) Copy(ctx context.Context, containerName, src, dst string) error {
_, stderr, err := runCmd(ctx, dcli.execer, "docker", "cp", src, containerName+":"+dst)
if err != nil {
return xerrors.Errorf("copy %s to %s:%s: %w: %s", src, containerName, dst, err, stderr)
}
return nil
}
Copy link
Member

Choose a reason for hiding this comment

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

Idea, non-blocking: could we also allow passing in an io.Reader instead that we convert to TAR archive format and stream to stdin / -?

Copy link
Member Author

Choose a reason for hiding this comment

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

I like the idea, although I don't see a benefit currently for its planned usage. If we have use-cases where we don't want to write files to disk it would definitely be the go-to approach.

@mafredri mafredri enabled auto-merge (squash) June 6, 2025 10:25
@mafredri mafredri merged commit a12429e into main Jun 6, 2025
34 checks passed
@mafredri mafredri deleted the mafredri/feat-agent-devcontainer-injection-2 branch June 6, 2025 10:33
@github-actions github-actions bot locked and limited conversation to collaborators Jun 6, 2025
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