Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(agent/agentcontainers): stop logging empty lines #18605

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 6 commits into from
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion agent/agentcontainers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,7 @@ func (api *API) maybeInjectSubAgentIntoContainerLocked(ctx context.Context, dc c
return xerrors.Errorf("set agent binary executable: %w", err)
}

// Make sure the agent binary is executable so we can run it.
// Make sure the agent binary is owned by a valid user so we can run it.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Missed feedback from #18611

if _, err := api.ccli.ExecAs(ctx, container.ID, "root", "/bin/sh", "-c", fmt.Sprintf("chown $(id -u):$(id -g) %s", coderPathInsideContainer)); err != nil {
return xerrors.Errorf("set agent binary ownership: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion agent/agentcontainers/devcontainercli.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ func (l *devcontainerCLILogWriter) Write(p []byte) (n int, err error) {
}
if logLine.Level >= 3 {
l.logger.Info(l.ctx, "@devcontainer/cli", slog.F("line", string(line)))
_, _ = l.writer.Write([]byte(logLine.Text + "\n"))
_, _ = l.writer.Write([]byte(strings.TrimSpace(logLine.Text) + "\n"))
continue
}
// If we've successfully parsed the final log line, it will successfully parse
Expand Down
5 changes: 5 additions & 0 deletions agent/agentcontainers/devcontainercli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"

Expand Down Expand Up @@ -343,6 +344,10 @@ func TestDevcontainerCLI_WithOutput(t *testing.T) {
t.Run("Up", func(t *testing.T) {
t.Parallel()

if runtime.GOOS == "windows" {
t.Skip("Windows uses CRLF line endings, golden file is LF")
}

// Buffers to capture stdout and stderr.
outBuf := &bytes.Buffer{}
errBuf := &bytes.Buffer{}
Expand Down
15 changes: 1 addition & 14 deletions agent/agentcontainers/testdata/devcontainercli/parse/up.golden
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,14 @@ Run: docker buildx build --load --build-context dev_containers_feature_content_s
#0 building with "orbstack" instance using docker driver

#1 [internal] load build definition from Dockerfile.extended

#1 transferring dockerfile: 3.09kB done
#1 DONE 0.0s

#2 resolve image config for docker-image://docker.io/docker/dockerfile:1.4

#2 DONE 1.3s


#3 docker-image://docker.io/docker/dockerfile:1.4@sha256:9ba7531bd80fb0a858632727cf7a112fbfd19b17e94c4e84ced81e24ef1a0dbc
#3 CACHED



#4 [internal] load .dockerignore
#4 transferring context: 2B done
#4 DONE 0.0s
Expand Down Expand Up @@ -61,17 +55,10 @@ Run: docker buildx build --load --build-context dev_containers_feature_content_s
#15 writing image sha256:275dc193c905d448ef3945e3fc86220cc315fe0cb41013988d6ff9f8d6ef2357 done
#15 naming to docker.io/library/vsc-devcontainers-template-starter-81d8f17e32abef6d434cbb5a37fe05e5c8a6f8ccede47a61197f002dcbf60566-features done
#15 DONE 0.0s

Run: docker buildx build --load --build-context dev_containers_feature_content_source=/var/folders/1y/cm8mblxd7_x9cljwl_jvfprh0000gn/T/devcontainercli/container-features/0.75.0-1744102171193 --build-arg _DEV_CONTAINERS_BASE_IMAGE=mcr.microsoft.com/devcontainers/javascript-node:1-18-bullseye --build-arg _DEV_CONTAINERS_IMAGE_USER=root --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp --target dev_containers_target_stage -f /var/folders/1y/cm8mblxd7_x9cljwl_jvfprh0000gn/T/devcontainercli/container-features/0.75.0-1744102171193/Dockerfile.extended -t vsc-devcontainers-template-starter-81d8f17e32abef6d434cbb5a37fe05e5c8a6f8ccede47a61197f002dcbf60566-features /var/folders/1y/cm8mblxd7_x9cljwl_jvfprh0000gn/T/devcontainercli/empty-folder
Run: docker run --sig-proxy=false -a STDOUT -a STDERR --mount type=bind,source=/code/devcontainers-template-starter,target=/workspaces/devcontainers-template-starter,consistency=cached --mount type=volume,src=dind-var-lib-docker-0pctifo8bbg3pd06g3j5s9ae8j7lp5qfcd67m25kuahurel7v7jm,dst=/var/lib/docker -l devcontainer.local_folder=/code/devcontainers-template-starter -l devcontainer.config_file=/code/devcontainers-template-starter/.devcontainer/devcontainer.json --privileged --entrypoint /bin/sh vsc-devcontainers-template-starter-81d8f17e32abef6d434cbb5a37fe05e5c8a6f8ccede47a61197f002dcbf60566-features -c echo Container started
Container started

Not setting dockerd DNS manually.

Running the postCreateCommand from devcontainer.json...



Running the postCreateCommand from devcontainer.json...
added 1 package in 784ms

{"outcome":"success","containerId":"bc72db8d0c4c4e941bd9ffc341aee64a18d3397fd45b87cd93d4746150967ba8","remoteUser":"node","remoteWorkspaceFolder":"/workspaces/devcontainers-template-starter"}
Loading