Skip to content

feat: collect rotated agent logs in support bundles#26055

Open
EhabY wants to merge 3 commits into
mainfrom
feat/support-bundle-rotated-agent-logs
Open

feat: collect rotated agent logs in support bundles#26055
EhabY wants to merge 3 commits into
mainfrom
feat/support-bundle-rotated-agent-logs

Conversation

@EhabY
Copy link
Copy Markdown
Contributor

@EhabY EhabY commented Jun 4, 2026

coder support bundle <workspace> only captured the active coder-agent.log, so a recent agent restart could leave useful history behind in rotated lumberjack files.

Add optional after support to the agent /debug/logs endpoint. Without after, /debug/logs preserves the existing active-log-only behavior. Support bundles now request after=now-24h and include matching rotated coder-agent-*.log files after the active log, without introducing a separate size cap or truncation marker.

Closes #25395

Generated by Coder Agents.

@EhabY EhabY changed the title feat: include rotated agent logs in support bundles feat: collect rotated agent logs in support bundles Jun 4, 2026
@EhabY EhabY marked this pull request as ready for review June 4, 2026 11:15
Copy link
Copy Markdown
Contributor Author

EhabY commented Jun 4, 2026

/coder-agents-review

@coder-agents-review
Copy link
Copy Markdown
Contributor

coder-agents-review Bot commented Jun 4, 2026

Chat: Review in progress | View chat
Requested: 2026-06-04 13:53 UTC by @EhabY
Spend: $56.13 / $100.00

deep-review v0.7.1 | Round 2 | d1d4b89..f51d46b

Last posted: Round 2, 15 findings (1 P2, 8 P3, 6 Nit), APPROVE. Review

Finding inventory

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 P2 Author fixed (f51d46b) agent/debuglogs.go:62 No aggregate size limit on after path; client reads full response into memory R1 Hisoka P2, Mafuuu P2, Chopper P2, Ryosuke P2, Meruem P3, Kite P3, Knov P3 Yes
CRF-2 P3 Author fixed (f51d46b) agent/debuglogs.go:54 Boundary marker written before file open; TOCTOU race leaves empty section R1 Mafuuu P3, Chopper Note Yes
CRF-3 P3 Author fixed (f51d46b) agent/debuglogs.go:126 os.Stat error silently discarded in multi-condition continue R1 Chopper P3 Yes
CRF-4 P3 Author fixed (f51d46b) agent/agent_test.go:3713 Active-first ordering invariant untested R1 Bisky P3, Chopper P3 Yes
CRF-5 P3 Author fixed (f51d46b) agent/agent_test.go:3676 No test for after with zero matching rotated files R1 Bisky P3 Yes
CRF-6 P3 Author fixed (f51d46b) codersdk/workspacesdk/agentconn.go:451 Doc comment says /tmp/coder-agent.log but path is configurable R1 Gon P2, Leorio P3 Yes
CRF-7 P3 Author fixed (f51d46b) codersdk/workspacesdk/agentconn.go:447 DebugLogsOptions exported with zero documentation R1 Leorio P3 Yes
CRF-8 P3 Author fixed (f51d46b) codersdk/workspacesdk/agentconn.go:456 DebugLogsWithOptions doc comment is vacuous R1 Leorio P3 Yes
CRF-9 P3 Author fixed (f51d46b) agent/debuglogs.go:146 disableWriteDeadline swallows SetWriteDeadline error; 20s timeout stays live on failure R1 Hisoka P3, Leorio Nit Yes
CRF-10 Nit Author fixed (f51d46b) agent/debuglogs.go:22 coderAgentBackupLogName uses "Backup" while rest of diff uses "rotated" R1 Gon Nit Yes
CRF-11 Nit Author fixed (f51d46b) support/support.go:668 24h lookback window has no named constant R1 Gon P3 Yes
CRF-12 Nit Author fixed (f51d46b) agent/debuglogs.go:65 io.Copy EOF guard is dead code; io.Copy returns nil on EOF, not io.EOF R1 Meruem Nit, Kite Note Yes
CRF-13 Nit Author fixed (f51d46b) cli/support_test.go:147 logs_truncated.txt assertion is vacuously true; no code produces that file R1 Zoro Nit Yes
CRF-14 Nit Author fixed (f51d46b) codersdk/workspacesdk/agentconn_internal_test.go:53 debugLogsPath test only covers non-zero After R1 Bisky Nit Yes
CRF-15 Note Dropped by orchestrator (standard Go interface extension pattern) codersdk/workspacesdk/agentconn.go:101 DebugLogs convenience wrapper with zero callers R1 Robin P3 No
CRF-16 Nit Open agent/debuglogs.go:25 coderAgentRotatedLogName is a *regexp.Regexp but name reads as a string; codebase uses Pattern/Regex/Re suffix R2 Gon Nit Yes

Round log

Round 1

Panel (16 reviewers). 1 P2, 8 P3, 5 Nit, 1 Note (dropped). Reviewed against d1d4b89..1f6ee66.

Round 2

Panel (16 reviewers). CRF-1 through CRF-14 all verified fixed. 1 new Nit. 2 Gon findings dropped (doc verbosity contradicts CRF-7/CRF-8 direction). Reviewed against d1d4b89..f51d46b.

About deep-review

CRF = Coder Review Finding (P0-P4, Nit, Note)

Reviewer Focus
Bisky tests
Chopper ops/errors
Churn-guard change verification
Ging language modernization
Gon naming
Hisoka edge cases
Killua perf
Kite change integrity
Knov contracts
Knuckle SQL
Kurapika security
Law decomposition
Leorio docs
Luffy product
Mafu-san process
Mafuuu contracts
Melody dispatch/pairing
Meruem structural
Nami frontend
Netero mechanical checks
Pariston premise testing
Pen-botter product gaps
Razor verification
Robin duplication
Ryosuke Go arch
Takumi concurrency
Zoro shape

🤖 Managed by Coder Agents.

@coder-tasks
Copy link
Copy Markdown
Contributor

coder-tasks Bot commented Jun 4, 2026

Documentation Check

Updates Needed

  • docs/support/support-bundle.md - The agent/logs.txt row in the bundle contents table currently says "The logs of the selected agent running in the workspace." This should be updated to reflect that it now includes rotated agent logs from the last 24 hours (via the new after query parameter), not just the active coder-agent.log.

Automated review via Coder Agents

Copy link
Copy Markdown
Contributor

@coder-agents-review coder-agents-review Bot left a comment

Choose a reason for hiding this comment

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

Clean, well-scoped feature. The backward-compatible opt-in via after, the strict lumberjack filename regex, and the boundary-marker format are all sound design choices. Test density is good (42.9%) and the four new agent subtests plus the integration test cover the important paths.

Severity count: 1 P2, 8 P3, 5 Nit.

The P2 is the missing aggregate size limit on the after path. Seven reviewers independently flagged that the endpoint streams all matching files without a cap while the client buffers the full response into memory via io.ReadAll. The old endpoint had a 10MB LimitReader; the new path relies entirely on lumberjack's config (~55MB theoretical max) in a different package with no reference or comment connecting them. Chopper noted a sharper failure mode: if lumberjack fails to rotate (disk full, permissions), the active log grows without bound and the after path serves it all.

Process observation: Commit 1 (8fece08d) built a 100MB cap, truncation header, client-side field, and bundle file. Commit 2 (1f6ee660) removed all of it. The net churn is ~562 lines for a ~288 net-line feature. As Mafu-san put it: the feature never needed this machinery since the lumberjack config already bounds total size. The fix: prefix on commit 2 is also inaccurate; nothing was broken, the approach changed. Consider squashing these commits.

Quote of the round, from Hisoka: "Two commits, two philosophies. Commit 1 built size caps and truncation signaling. Commit 2 tore them out, trusting lumberjack's config in a different package. The code that remains is clean and functional. The hidden coupling between cli/agent.go's rotation config and agent/debuglogs.go's unbounded streaming is the real opponent here."

This is a first-round panel review.


Generated by Coder Agents on behalf of @mafredri

🤖 This review was automatically generated with Coder Agents.

Comment thread agent/debuglogs.go Outdated
Comment thread agent/debuglogs.go Outdated
Comment thread agent/debuglogs.go Outdated
Comment thread agent/agent_test.go
Comment thread agent/agent_test.go
Comment thread agent/debuglogs.go Outdated
Comment thread support/support.go Outdated
Comment thread agent/debuglogs.go Outdated
Comment thread cli/support_test.go Outdated
Comment thread codersdk/workspacesdk/agentconn_internal_test.go
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

Docs preview

📖 View docs preview for docs/support/support-bundle.md

Copy link
Copy Markdown
Contributor Author

EhabY commented Jun 4, 2026

/coder-agents-review

Copy link
Copy Markdown
Contributor Author

EhabY commented Jun 4, 2026

Generated by Coder Agents.

Addressed the review feedback in f51d46b:

  • Added a 100 MiB aggregate cap for the after debug log path.
  • Moved boundary writes after successful file opens and logged stat/write-deadline errors.
  • Added tests for the cap, active-first ordering, zero rotated matches, and zero After path encoding.
  • Updated SDK docs and docs/support/support-bundle.md for the 24-hour rotated log behavior.

Copy link
Copy Markdown
Contributor Author

EhabY commented Jun 4, 2026

/coder-agents-review

Copy link
Copy Markdown
Contributor

@coder-agents-review coder-agents-review Bot left a comment

Choose a reason for hiding this comment

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

All 14 R1 findings verified fixed. The fixes are clean and target root causes: CRF-1 (size cap) solved with a remaining counter and io.LimitReader in the loop, tested with a dedicated internal test that verifies exact byte counts. CRF-2 (TOCTOU) solved by moving the boundary write inside the closure after a successful os.Open. CRF-3 (silent stat error) split into its own check with a Warn log. Each fix is proportional and introduces no regressions.

Severity count: 1 new Nit.

Process observation: the PR description still says "without introducing a separate size cap or truncation marker," but the code now has debugLogsWithRotatedLimitBytes = 100 MiB and a truncation warning. The docs and code comments are accurate; only the description is stale. Worth updating before merge.

Quote of the round, from Hisoka: "I pulled every thread this diff offers and nothing snapped."

🤖 This review was automatically generated with Coder Agents.

Comment thread agent/debuglogs.go
debugLogsWithRotatedLimitBytes = 100 * 1024 * 1024
)

var coderAgentRotatedLogName = regexp.MustCompile(`^coder-agent-\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}\.\d{3}\.log$`)
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.

Nit [CRF-16] coderAgentRotatedLogName is a *regexp.Regexp but reads as a string name. The codebase uses type-indicating suffixes for regex variables: timestampRegex, labelKeyRegex, consecutiveHyphenRegex, WindowsDriveRegex, syntheticPasteFileNamePattern. Consider coderAgentRotatedLogPattern to match the convention. (Gon)

🤖

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.

Support bundle: include rotated agent logs

1 participant