Skip to content

fix(logs): harden task streaming and SSE handling - #318

Open
Serta莽 脰zercan (sozercan) wants to merge 6 commits into
fix/kubernetes-inventory-paginationfrom
fix/task-log-streaming
Open

Serta莽 脰zercan (sozercan) wants to merge 6 commits into
fix/kubernetes-inventory-paginationfrom
fix/task-log-streaming

Conversation

@sozercan

Copy link
Copy Markdown
Member

Summary

Stacked salvage from #280. Base: #314 (fix/kubernetes-inventory-pagination).

  • Add bounded task-log lines, heartbeats, safe CR/LF framing, terminal SSE errors, and writer/scanner error propagation.
  • Hand established Kubernetes log streams off from Fiber safely while preserving request deadlines and cancellation ownership.
  • Give CLI streaming a bounded response-header timeout, bounded error reads, and a size-limited SSE parser without imposing an overall stream timeout.

Scope

This PR changes task-log follow streaming and the CLI SSE client only. It does not change backend inventory pagination; the stack base is used to keep the review diff to one commit.

Verification

  • go test ./internal/api ./internal/cli/client ./cmd/cli -run 'TaskLog|SSE|StreamTaskLogs' -count=1
  • make lint-fix && make test
  • Full required CI

After #314 merges, this PR should be retargeted to main.

Signed-off-by: Sertac Ozercan <sozercan@gmail.com>
Signed-off-by: Sertac Ozercan <sozercan@gmail.com>
Signed-off-by: Sertac Ozercan <sozercan@gmail.com>
Signed-off-by: Sertac Ozercan <sozercan@gmail.com>
Signed-off-by: Sertac Ozercan <sozercan@gmail.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

馃挕 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4284a87401

鈩癸笍 About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 馃憤.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread internal/cli/client/client.go Outdated
Comment thread internal/api/handlers.go Outdated
Comment thread internal/api/handlers.go Outdated
Signed-off-by: Sertac Ozercan <sozercan@gmail.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

馃挕 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7d408ee1d3

鈩癸笍 About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 馃憤.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment on lines +63 to +66
if transport, ok := http.DefaultTransport.(*http.Transport); ok {
clone := transport.Clone()
clone.ResponseHeaderTimeout = responseHeaderTimeout
return &http.Client{Transport: clone}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve the default client's configured transport

When an embedding program configures http.DefaultClient.Transport鈥攁 supported pattern for mTLS, Kubernetes auth, proxies, or tracing鈥攖hese constructors previously honored it, but now they consult only http.DefaultTransport and silently use an unrelated clone. Consequently every API request can bypass the caller's required authentication or routing. The fresh evidence after the earlier review is that the new fallback preserves a customized http.DefaultTransport, but the constructor still never reads http.DefaultClient.Transport.

Useful? React with 馃憤聽/ 馃憥.

Comment thread internal/api/handlers.go
Comment on lines +935 to +936
case <-ctx.Done():
return nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Report stream deadline expiration to the client

When the inherited request context has a deadline that expires after the Kubernetes stream is established, this branch closes the SSE response without emitting an error. StreamTaskLogs interprets that clean EOF as success, so orka task logs --follow silently exits while the task may still be running; distinguish DeadlineExceeded here and send a terminal error event before closing.

Useful? React with 馃憤聽/ 馃憥.

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.

1 participant