Skip to content

feat(logs): stream logs with follow#20

Merged
swkeever merged 4 commits into
mainfrom
skeever/log-stream-cli
Jun 29, 2026
Merged

feat(logs): stream logs with follow#20
swkeever merged 4 commits into
mainfrom
skeever/log-stream-cli

Conversation

@swkeever

Copy link
Copy Markdown
Collaborator

Summary

  • add a no-timeout project log stream client for POST /projects/{projectID}/logs/stream
  • wire --follow for function and frontend runtime/build logs
  • stop followed build logs when the deployment reaches a terminal status, then run a duplicate-suppressed catch-up search

Depends on Kong/volcano-hosting#471.

Tests

  • make lint
  • go test ./...
  • go build ./...

swkeever added 4 commits June 26, 2026 12:01
The deployment follow loop returned as soon as the log stream closed,
skipping the duplicate-suppressed catch-up search whenever the stream
ended (EOF) before the poller observed a terminal status. Keep polling
after a clean stream shutdown and check terminal status immediately so
the catch-up search still runs without waiting for the next poll.
The runtime --follow loop ended as soon as the SSE stream closed, so a
dropped connection (load-balancer cap, redeploy, network blip) silently
stopped the tail even though the backend supports resuming. Reconnect
from the last stream cursor (Last-Event-ID) until the context is
canceled, relying on the server's overlap window and seen-set dedup to
avoid replaying recent events.

Deployment (build) follow is unchanged: its terminal poll and
duplicate-suppressed catch-up search already recover logs missed during
a disconnect.
@swkeever swkeever marked this pull request as ready for review June 29, 2026 15:07
@swkeever swkeever requested a review from a team as a code owner June 29, 2026 15:07
Copilot AI review requested due to automatic review settings June 29, 2026 15:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@swkeever swkeever enabled auto-merge June 29, 2026 15:46

@marckong marckong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Summary

Adds a --follow flag to function/frontend log commands, backed by a new no-timeout SSE stream client (internal/api/log_stream.go) and a shared follow-loop package (internal/logfollow). Runtime follows reconnect transparently from the last event cursor; build follows stop at terminal deployment status and run a duplicate-suppressed catch-up search. The bulk of the +2478/-2476 line count is a regeneration of apiclient/client.gen.go.

  • New stream client manually sets Authorization: Bearer / Accept: text/event-stream and a 1 MB SSE scanner buffer, separate from the timeout-bound default client.
  • logfollow.Deployment coordinates a reader goroutine + terminal-status poller; logfollow.Runtime wraps a self-reconnecting stream.

Review

Clean, well-structured change with solid test coverage — build, go test, and the affected packages all pass locally. The concurrency in the deployment follow loop is careful (buffered errCh, awaitStream before snapshot, defer cancel()), so the catch-up reads printed only after the reader goroutine has exited — no races or goroutine leaks spotted. A few verifications worth noting:

  • Dropping resp.JSON503 in searchProjectLogs is correct — the regenerated SearchProjectLogsClientResponse no longer has that field, so it's required to compile.
  • The manual Bearer scheme in the stream client matches authorizationEditor, and projectLogsStreamURL correctly handles the trailing slash from generatedClientBaseURL.
  • Terminal-status sets (active/deleted/deleting/failed, excluding provisioning) line up with the generated enums.

Overall correctness: correct. No blocking issues; existing code and tests are unaffected. Approving. 🚀

@swkeever swkeever added this pull request to the merge queue Jun 29, 2026
Merged via the queue into main with commit c80c0a5 Jun 29, 2026
8 of 9 checks passed
@swkeever swkeever deleted the skeever/log-stream-cli branch June 29, 2026 15:57
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.

3 participants