Skip to content

Capture BuildKit output in build logs#570

Merged
phinze merged 1 commit intomainfrom
phinze/mir-658-build-logs-missing-buildkit-output-and-onbuild-command
Feb 5, 2026
Merged

Capture BuildKit output in build logs#570
phinze merged 1 commit intomainfrom
phinze/mir-658-build-logs-missing-buildkit-output-and-onbuild-command

Conversation

@phinze
Copy link
Contributor

@phinze phinze commented Feb 4, 2026

Fixes MIR-658

Build logs were only showing the detection phase stuff, but all the
juicy BuildKit output (layer pulls, cache status, command output) that
you see during miren deploy was missing from miren logs --build.

Turns out we had two WithStatusUpdates callbacks - one for persisting
logs, one for streaming to the client - but WithStatusUpdates just
overwrites, it doesn't chain. So the streaming callback was clobbering
the persistence one.

Combined them into a single callback that does both. Now build logs
include everything: layer info, phase markers, cache status, and
importantly the actual command output (like bun install or go build
output, and onbuild commands).

@phinze phinze requested a review from a team as a code owner February 4, 2026 17:27
@coderabbitai
Copy link

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

The change refactors servers/build/build.go to deduplicate and scope BuildKit vertex log entries by tracking vertexStarted and vertexCompleted events. It replaces the previous per-status callback with a single combined status callback that: logs vertex start once, logs vertex completion when cached once, writes per-line BuildKit output (trimming whitespace) to the build log, and forwards the raw SolveStatus payload to the status client when connected. Vertex tracking is initialized before status callbacks are registered; existing phase-based status messages are preserved.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@servers/build/build.go`:
- Around line 770-779: The code trims leading whitespace when logging build
output (in the loop over ss.Logs where lines are processed and passed to
buildLog.write), which destroys indentation for stack traces and formatted
output; replace the call to strings.TrimSpace(line) with a trailing-only trim
(use strings.TrimRight(line, "\r") or equivalent) so you only strip Windows CR
characters but preserve leading spaces before calling buildLog.write.

Build logs from `miren logs --build` were only showing detection phase
events, missing all the BuildKit output that's visible during deploy.

Root cause: two WithStatusUpdates callbacks were registered, but the
second one overwrote the first (it's a simple assignment, not chaining).
Combined them into a single callback that both persists logs and sends
to the client.

Now captures vertex start/complete status, cache hits, and command
stdout/stderr including onbuild command output.
@phinze phinze force-pushed the phinze/mir-658-build-logs-missing-buildkit-output-and-onbuild-command branch from 842d2f3 to aed76c9 Compare February 4, 2026 20:34
Copy link
Contributor

@evanphx evanphx left a comment

Choose a reason for hiding this comment

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

aaaaaaah!

@phinze phinze added this pull request to the merge queue Feb 5, 2026
Merged via the queue into main with commit b1ed72f Feb 5, 2026
9 checks passed
@phinze phinze deleted the phinze/mir-658-build-logs-missing-buildkit-output-and-onbuild-command branch February 5, 2026 14:08
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.

2 participants