Skip to content

feat: build output travels on the log stream, labelled with its deployment (part of #215) - #534

Merged
samuelmbabhazi merged 6 commits into
mainfrom
feat/215-build-output
Nov 27, 2026
Merged

samuelmbabhazi merged 6 commits into
mainfrom
feat/215-build-output

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

Part of #215 (M3.3), per ADR 0032 (#531). A build's output now reaches the control plane. It builds on #533 (BuildImage), and through it on #532 (the build lane), and contains their commits until they merge; the base is main.

What changed

  • logs.proto — LogEntry.action_id (6): the action whose output the line is, container then empty. Backward compatible: today's control plane drops such an entry and keeps the rest of the batch (checked).
  • Agent:
    • logship.BuildOutput is the build's line sink. A build writes to it without ever waiting. It keeps up to 8192 lines and 8 MiB, the oldest dropped first.
    • The shipper relays these lines in the same batches as the containers' lines, numbered.
    • A line is forgotten only once its batch is acknowledged. A stream that fails before then sends it again on the next one, so delivery is at least once.
    • No cursor is written for build lines.
  • Control plane:
    • An entry is a container's line or an action's output, never both.
    • MetricsTargets.buildsOnNode keeps only buildImage actions queued on that very node with a deployment key d:<deployment>:…, and returns their deployment's application, environment and project.
    • Such lines are written with instance and stream set to build, plus deployment.
    • The application's log search adds -stream:=build, so build lines never mix with the application's. I checked the LogsQL on a real VictoriaLogs v1.54.
  • SPEC documents the labels and the agent's bounds.

Reading build output back (a route for the deployment page) and the page itself (#265) come next.

How it was tested

  • Go:

    • lines are tagged with the action and carry no container;
    • nothing is forgotten before its acknowledgement;
    • a line is resent on the next stream after a failed one;
    • the 8192-line and 8 MiB bounds drop the oldest first;
    • writing never blocks with nobody reading.

    go test -race ./agent/internal/logship/ and golangci-lint are clean.

  • TypeScript unit:

    • entries with both, neither, a malformed id or an injected id are refused;
    • a line of a build the node was not given is dropped;
    • a build line never comes back through an application search;
    • the ingest asks only for the actions named, and writes the deployment's labels.
  • Integration, PostgreSQL (build-output.integration.spec.ts): a build queued on another node, a pull of the same deployment, a build without a deployment key and an unknown id are all refused; only the right build is kept. The fleet and observability integration suites show only the known environment failures.

  • VictoriaLogs v1.54, run on the host's Docker: -stream:=build and deployment:="…" select what is expected.

Security considerations

)

ADR 0032: each lane has its own executor gate. Operations of a lane run one at a time, two lanes side by side, so a long build leaves the server's other actions free. The default lane holds every existing action.

Signed-off-by: samuel mbabhazi <[email protected]>
…ss BuildKit (part of #215)

ADR 0030, 0032: the action is validated field by field, runs in the build lane, fetches the repository over HTTPS with its token as a session secret under a random name, builds with BuildKit's Dockerfile frontend, pushes with the grant for the target's registry only, and answers the digest. Failures have fixed texts; the output is redacted and bounded, and goes to the log stream in the next step.

Signed-off-by: samuel mbabhazi <[email protected]>
…with a real BuildKit

The three fixed texts of BuildImage become reasons (build_failed, build_timeout, builder_unavailable), labelled in the web UI and in French. The agent job starts BuildKit 0.35.1 and a registry and builds this repository at the commit under test.

Signed-off-by: samuel mbabhazi <[email protected]>
…yment (part of #215)

ADR 0032: LogEntry gains action_id. The agent keeps a build's lines in a bounded buffer until the stream acknowledges them and sends them again on the next one; the control plane accepts them only for a buildImage action it queued on that node for a deployment, writes them with the deployment's labels and stream build, and keeps them out of the application's log search.

Signed-off-by: samuel mbabhazi <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 30 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 79412a3 and b468452.

Files ignored due to path filters: 2

  • lib/gen/shipkeep/agent/v1/logs.pb.go is excluded by !**/*.pb.go, !**/gen/**, !lib/gen/**
  • packages/proto-ts/src/gen/shipkeep/agent/v1/logs_pb.ts is excluded by !**/gen/**, !packages/proto-ts/src/gen/**
Files selected for processing: 15

  • agent/internal/agent/gateway.go
  • agent/internal/logship/builds.go
  • agent/internal/logship/builds_test.go
  • agent/internal/logship/shipper.go
  • apps/api/src/modules/observability/application/logs-ingest.spec.ts
  • apps/api/src/modules/observability/application/logs-ingest.ts
  • apps/api/src/modules/observability/application/metrics-ingest.spec.ts
  • apps/api/src/modules/observability/application/metrics-queries.spec.ts
  • apps/api/src/modules/observability/application/ports.ts
  • apps/api/src/modules/observability/build-output.integration.spec.ts
  • apps/api/src/modules/observability/domain/logs.spec.ts
  • apps/api/src/modules/observability/domain/logs.ts
  • apps/api/src/modules/observability/infrastructure/prisma-metrics-targets.store.ts
  • docs/SPEC.md
  • proto/shipkeep/agent/v1/logs.proto
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow proto / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed⏩ skippedNov 27, 2026, 11:45 AM

Signed-off-by: samuel mbabhazi <[email protected]>

# Conflicts:
#	agent/go.mod
#	agent/go.sum
#	agent/internal/agent/gateway.go
#	agent/internal/buildkit/testdata/app/Dockerfile
@samuelmbabhazi
samuelmbabhazi merged commit 51ee778 into main Nov 27, 2026
28 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the feat/215-build-output branch November 27, 2026 11:56
samuelmbabhazi added a commit that referenced this pull request Nov 27, 2026
…#539)

Part of #265 (screen 15, "the build and release log of one deployment,
streamed while it runs").

## What changed

**API**
- `GET
…/applications/{applicationId}/deployments/{deploymentId}/build-output`
(`environment.read`, also open to API tokens with that permission)
answers one deployment's build output, oldest first: `kept`, and `lines`
with `time`, `line`, `truncated`.
- It reads the lines the control plane labelled with that deployment
(#534): `instance` and `stream` `build`, field `deployment`. By default
it starts an hour before the deployment started, because the agent
stamps lines with its own clock. A live view passes `from`, the exact
time of its last line, to the nanosecond. `limit` defaults to 500, which
is also the maximum.
- A deployment of another application is not found, checked in SQL
(`deployments.application_id`).
- Authorization follows the application's log search (#488): authorized
in a short transaction, the store read with no lock or transaction held,
then authorized again before any line leaves.

**Web**
- The "will appear here" note on the deployment page is replaced by a
**Build output** section under the timeline. It follows the "Full log"
block of design screen 15: a title, "Rootless BuildKit" on the right, a
mono block of at most 420 px, each line prefixed with its time.
- While the deployment runs, the section reads again every 3 s, and
twice more once it has finished. Each read starts 3 s before the last
line, because batches of one build may reach the store side by side. A
line read twice shows once.
- The view follows the end unless the reader scrolled up. It keeps the
last 8192 lines, as many as the agent holds for one build, and says so
when it drops older ones.
- An image deployment promises no build output. A deployment that runs a
release command says its output is not collected yet.
- The page says when the installation keeps no logs, and when the read
fails, with a Retry button.
- French translations added.

**Docs**: SPEC section 12 describes the route and the live view; section
8 points the timeline at it. The route/role matrix is regenerated.

## Why

#215 builds now run (#533, #537) and their output reaches VictoriaLogs
(#534), but nobody could see it. Without that, a failed build is a
failed deployment with no reason anyone can read.

## How it was tested

- Unit tests:
- the LogsQL query: exact time, injection attempts in each identifier,
records that are not build lines;
- the service: margin before the start, a deployment of another
application, no store, access withdrawn while the store answers;
  - the line merge: repeats, order, the 8192 bound;
- the page: live reads with `from`, a line read twice, reads stop after
the deployment finished, no log store, a read failure then Retry.
- Integration with PostgreSQL (`build-output-http.integration.spec.ts`):
  - viewer access, the exact query, `from` to the nanosecond;
  - a `from` with no offset, or in the future, is refused;
- an outsider, and a deployment under another application, get 404 and
the store is never asked.
- Mutation check: dropping the application filter from the SQL fails
that test.
- Chromium against the production build (`github.browser.spec.ts`): a
Git application with a Dockerfile is deployed on an enrolled server, and
its page shows the build output a fake log store answers, read again
while it runs. Checked under the production CSP and axe.
- Locally: web 404/404 unit tests, API 973/973 unit tests. Integration
469 passed; the only failures are the known local ones (PostgreSQL 18's
23001 ×3, and the metrics, S3 and Distribution suites, which need a
container runtime).

The diff is about 1100 lines excluding generated code, about half of it
tests.

## Security considerations

- Build lines are redacted by the agent before they leave the server
(#534): secret values, the Git token and the registry password. This
route only reads what was stored.
- Identifiers in the LogsQL query are validated as UUIDs. `from` must be
RFC 3339 with an offset, and enters the query only through the strict
nine-digit form, so no user text reaches the query.
- Access is `environment.read`, the same as application logs. Access is
checked again after the store answers, so a reader who loses access
during the read gets nothing.

## UI validation

Screenshots (desktop and mobile, English and French) were shared with
the maintainer. This PR waits for their validation before merging.

---------

Signed-off-by: samuel mbabhazi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant